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
}
}
イムをグループ化し、uはすぐに知っているようにプロパティinspector->そして変化型と行く:以下は私のコードです – anuj
チェックされていない@Nishant Bhindi – anuj
あなたはそのプロパティを割り当てた後に得られる出力を表示できますか? –