内容简介:翻译自:https://stackoverflow.com/questions/20313611/custom-uitableviewcell-initialization-not-called
我有一些图像和标签的自定义UiTablleviewCell,我想在tableview单元格中旋转标签…所以我想编辑initWithStyle方法,但似乎从未调用过.
- (id)initWithStyle:(UITableViewCellStyle)stylereuseIdentifier:(NSString*)reuseIdentifier{
NSLog(@"creating cell");
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
}
return self;}
但在我的日志中,我看不到这条消息.在tableview中我有标准的cellForRow方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"messagesCell";
TBCellMessagesCell *cell = (TBCellMessagesCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// smt stuff
return cell;
}
所以我想知道tableview如何初始化tableviewcells,我可以考虑一些解决方法,但我想让它干净.
谢谢.
如果单元格来自故事板或nib文件,则不调用initWithStyle:reuseIdentifier,而是调用initWithCoder :.
这是覆盖的initWithCoder的典型实现::
-(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
// Do your custom initialization here
}
return self;
}
如果您需要在自定义初始化期间访问IBOutlet,则无法工作.
翻译自:https://stackoverflow.com/questions/20313611/custom-uitableviewcell-initialization-not-called
以上所述就是小编给大家介绍的《ios – 未调用自定义UITableVIewCell初始化》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Landing Page Optimization
Tim Ash / Wiley Publishing / 2008-1-29 / USD 29.99
在线阅读本书 How much money are you losing because of poor landing page design? In this comprehensive, step-by-step guide, you’ll learn all the skills necessary to dramatically improve your bottom li......一起来看看 《Landing Page Optimization》 这本书的介绍吧!
在线进制转换器
各进制数互转换器
HSV CMYK 转换工具
HSV CMYK互换工具