2017-08-31 7 views
2

HeaderView(.xib)をUITableViewに追加しました。ViewController.Butをロードすると正しく表示されます。tableViewの任意の位置までスクロールして、どのようにtableViewヘッダーを非表示にするのですか?それが感謝される私を助けることができる。 storyboard-でスクロールアップ/スクロールするときのUITableViewヘッダーの表示/非表示方法は?

class ViewController: UIViewController,UITableViewDataSource,UIScrollViewDelegate { 


@IBOutlet var myTable : UITableView! 
var array = ["See All Local Deals","Food & Drink","Kids Activities","Taxi" , "Shopping" , "Local Tradesmen" , "Tattoo shop" , "Car Hire" , "Health & Fitness" , "Beauty & Spas" , "Home & Garden" , "Local Services" , "Nightlife" , "Wedding Planning" , "Holiday rentals"] 

lazy var headerView : HeaderView? = { 
    return Bundle.main.loadNibNamed("HeaderView", owner: self, options: nil)?[0] as? HeaderView 

}() 

override func viewDidLoad() { 
    super.viewDidLoad() 

    self.myTable.dataSource = self 
    self.myTable.tableHeaderView = headerView 

} 

func numberOfSections(in tableView: UITableView) -> Int { 
return 1 
} 
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return array.count 
} 

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyCell 

    cell.lblText.text = array[indexPath.row] 
    return cell 

} 
} 

答えて

3

>あなたtableview-を選択>平野
から@Nishant Bhindiをチェック enter image description here

+0

イムをグループ化し、uはすぐに知っているようにプロパティinspector->そして変化型と行く:以下は私のコードです – anuj

+0

チェックされていない@Nishant Bhindi – anuj

+0

あなたはそのプロパティを割り当てた後に得られる出力を表示できますか? –

関連する問題