Başlıklarına dokunarak genişletilebilir bir tablo görünümü oluşturmak istiyorum, üstbilgiyi yerleştirmek için viewForHeaderInSection adlı bir headerfooterview sınıfına sahibim ve bölümü yeniden yüklemeye çalışana kadar güzel görünüyor bölüm katlandığında alt görünüm kaybolur. kodtableview üstbilgisi alt görünümü bölümleri yeniden yüklerken göz ardı kesiliyor
override func viewDidLoad() {
super.viewDidLoad()
tableView.registerClass(CustomHeaderTableViewCell.self, forHeaderFooterViewReuseIdentifier: "header")
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return data.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == selectedSection {
return 0
} else {
return data[section].count
}
}
func expandCollapse(sender: UIButton) {
self.selectedSection = sender.tag
tableView.reloadSections(NSIndexSet(index: sender.tag), withRowAnimation: .None)
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header: CustomHeaderTableViewCell = tableView.dequeueReusableHeaderFooterViewWithIdentifier("header") as! CustomHeaderTableViewCell
let button = UIButton(type: UIButtonType.System) as UIButton
button.frame = header.bounds
button.backgroundColor = UIColor.greenColor()
button.setTitle("Test Button", forState: UIControlState.Normal)
button.addTarget(self, action: #selector(MainWitness.expandCollapse), forControlEvents: UIControlEvents.TouchUpInside)
button.tag = section
header.addSubview(button)
header.textLabel!.text = "TRENDS"
return header
}
Tablo görüntüleme kodunda ne tür bilgiler var? – hariszaman
func numberOfSectionsInTableView (tableView: UITableView) -> Int { veri dönüşü } bu bölüm çalışıyor –
ya ne? – hariszaman