objective-c – 为什么不调用自定义基于nib的表单元格的init方法

栏目: Objective-C · 发布时间: 7年前

内容简介:而不是 – (id)init被调用 – (id)initWithCoder:(NSCoder *)将调用aDecoder.此时,如果您需要访问可以覆盖的出口 – (void)awakeFromNib,它将被连接起来,这将在连接对象后调用.翻译自:https://stackoverflow.com/questions/6942152/why-does-the-init-method-of-a-custom-nib-based-table-cell-not-get-called

我有一个基于nib的表视图单元格,我在Interface builder中创建.我将表视图单元的类设置为从UITableViewCell扩展的FooTableViewCell.

在FooTableViewCell中,我重写了这样的init方法:

-(id)init{

    if ((self = [super init])){
      // My init code here
    }
    return self;
}

我现在期望在实例化时调用它.但是会显示表视图,但从不调用该方法.

我可以解决这个问题,但我想完全理解它,对我而言,如果没有调用init方法,对象是如何生存的还不清楚.

而不是 – (id)init被调用 – (id)initWithCoder:(NSCoder *)将调用aDecoder.此时,如果您需要访问可以覆盖的出口 – (void)awakeFromNib,它将被连接起来,这将在连接对象后调用.

翻译自:https://stackoverflow.com/questions/6942152/why-does-the-init-method-of-a-custom-nib-based-table-cell-not-get-called


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Introduction to Graph Theory

Introduction to Graph Theory

Douglas B. West / Prentice Hall / 2000-9-1 / USD 140.00

For undergraduate or graduate courses in Graph Theory in departments of mathematics or computer science. This text offers a comprehensive and coherent introduction to the fundamental topics of graph ......一起来看看 《Introduction to Graph Theory》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具