在情节提要中使用自定义tableviewcell时,IBOutlet的值为零 [英] IBOutlet's are nil when using custom tableviewcells in a storyboard
问题描述
情节提要具有一个带有一个原型单元的表格视图,UITableView具有一个原型单元,并且已配置为自定义UITableViewCell子类.
The storyboard has a tableview with one prototype cell, the UITableView has a prototype cell and it has been configured to be the custom UITableViewCell sublclass.
原型单元已正确连接到自定义子容器,IBOutlets的配置正确,但是由于某些原因,当我得到该单元时,它结束了所有自定义子视图.
The prototype cell is hooked up to the custom sublcass correctly, the IBOutlets are configured correctly, but for some reason when I get the cell it ends up all my custom subviews are nil.
我还对其进行了配置,以使customIdentifiers相同.
I've also configured it so that the customIdentifiers are the same.
推荐答案
所以我面临的问题是一个怪异的疏忽,当您在情节提要中识别出复用标识符时,您不必调用
So the problem that I was facing was a weird oversight, when you identify a reuseIdentifier in the storyboard, you don't have to call
- (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier;
在TableView上.如果这样做,实际上会破坏预期的功能.
on the TableView. If you do, this will actually BREAK the functionality it's intended to do.
当与自定义UITableViewCells混淆时,只需将reuseIdentifiers设置为通用即可,我相信这将为您提供幕后的registerClass.如果您自己做,那就行不通了.
When messing with custom UITableViewCells, just set up the reuseIdentifiers to be in common and that will do the registerClass behind the scenes for you I believe. If you do it yourself, it won't work.
这篇关于在情节提要中使用自定义tableviewcell时,IBOutlet的值为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!