【发布时间】:2017-03-08 14:53:31
【问题描述】:
我正在 XIB 文件中构建我的部分标题视图:
这是一个 XIB 文件,由 UISearchBarController 和 UIView 组成
我在 viewDidLoad 的 tableViewController 中注册它:
tableView.register(UINib(nibName: "MessagesSH", bundle: nil), forHeaderFooterViewReuseIdentifier: "MessagesSH")
我叫它viewForHeaderInSection:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// Below is the where the app crashes
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "MessagesSH") as? MessagesSH
return headerView
}
当我运行应用程序时,它崩溃了:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid nib registered for identifier (MessagesSH) - nib must contain exactly one top level object which must be a UITableViewHeaderFooterView instance'
【问题讨论】:
标签: ios xcode uitableview uisearchdisplaycontroller uitableviewsectionheader