标题自定义视图:在展开可选值时意外发现为零

时间:2015-10-25 19:58:59

标签: ios swift null tableview

运行代码时出错。错误全部在viewForHeaderInSection函数的下面一行中。

let header:friendsListSectionHeader = self.friendsTableView.dequeueReusableHeaderFooterViewWithIdentifier("friendsSection") as! friendsListSectionHeader

我在viewDidLoad中这样引用它。

let nib2 = UINib(nibName: "friendsListSectionHeader", bundle: nil)
        friendsTableView.registerNib(nib2, forCellReuseIdentifier: "friendsSection")

如果可以做任何事情,我确实有一个上面的单元格的自定义视图。一切都在构建,但是我得到一个错误,我在意外地找到了一个在解包Option值时为零的错误。

我的.xib和UITableViewHeaderFooterView类都被正确引用。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您只是使用了错误的注册方法,而是注册了一个您应该使用的单元格registerNib:forHeaderFooterViewReuseIdentifier: