Anonymous
ViewForHeaderInsection не призван для моего представления о таблице
Сообщение
Anonymous » 27 июн 2025, 18:53
У меня есть uitableview, я пытаюсь добавить Headerview в свой uitableview .
Однако viewforheaderinsection не вызывается. Но я вижу, что TitleForHeaderInsection вызывается или отображается. Я также пытался использовать пользовательский заголовок сотовой связи для этого, и он также не работает. < /P>
Я понятия не имею, что делаю не так.
Код: Выделить всё
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Groceries"
tableView.registerNib(UINib(nibName: "TransactionSpecifiedCategoriesTableViewCell", bundle: nil), forCellReuseIdentifier: "TransactionSpecifiedCategoriesTableViewCell")
tableView.registerNib(UINib(nibName: "TransactionSpecifiedCategoriesHeaderViewCell", bundle: nil), forHeaderFooterViewReuseIdentifier: "TransactionSpecifiedCategoriesHeaderViewCell")
tableView.tableFooterView = UIView(frame: CGRectMake(0, 0, 0, 0))
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let footerView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 100))
footerView.backgroundColor = UIColor.blackColor()
return footerView
//let header: UITableViewHeaderFooterView = view as UITableViewHeaderFooterView
//var headerView = UIView(frame: CGRectMake(0, 0, 100, 320))
//headerView.backgroundColor = UIColor.blackColor()
//
//return headerView
}
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 200.0
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "First section header title"
}
Подробнее здесь:
https://stackoverflow.com/questions/291 ... table-view
1751039630
Anonymous
У меня есть uitableview, я пытаюсь добавить Headerview в свой uitableview . Однако viewforheaderinsection не вызывается. Но я вижу, что TitleForHeaderInsection вызывается или отображается. Я также пытался использовать пользовательский заголовок сотовой связи для этого, и он также не работает. < /P> Я понятия не имею, что делаю не так.[code]override func viewDidLoad() { super.viewDidLoad() self.title = "Groceries" tableView.registerNib(UINib(nibName: "TransactionSpecifiedCategoriesTableViewCell", bundle: nil), forCellReuseIdentifier: "TransactionSpecifiedCategoriesTableViewCell") tableView.registerNib(UINib(nibName: "TransactionSpecifiedCategoriesHeaderViewCell", bundle: nil), forHeaderFooterViewReuseIdentifier: "TransactionSpecifiedCategoriesHeaderViewCell") tableView.tableFooterView = UIView(frame: CGRectMake(0, 0, 0, 0)) } func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let footerView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 100)) footerView.backgroundColor = UIColor.blackColor() return footerView //let header: UITableViewHeaderFooterView = view as UITableViewHeaderFooterView //var headerView = UIView(frame: CGRectMake(0, 0, 100, 320)) //headerView.backgroundColor = UIColor.blackColor() // //return headerView } func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 200.0 } func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return "First section header title" } [/code] Подробнее здесь: [url]https://stackoverflow.com/questions/29144793/viewforheaderinsection-not-being-called-for-my-table-view[/url]