开发者

iPhone: Is there a way to loadFromNib AND have a reuseIdentifier?

I am thinking about this problem now for very lo开发者_开发百科ng.

I try to use different types of cells in my table, that each have their own cell controller and have a reuseIdentifier AND load from NIB.

The problem boils down to this: You can either init a Cell via [UITableViewCell initWithStyle:reuseIdentifier:] or via [NSBundle loadNibNamed:owner:options:].

Do i overlook something or is there a possibility to have both: load from nib and use reuseIdentifier?


Asking a question can sometimes lead you to the right track :I

The answer can be found here: https://discussions.apple.com/thread/1664267?threadID=1664267


I am hopping you are using customized UITableViewCell. reuseIdentifier is readonly property so you couldn't set it but there are two ways,

1) Open your custom nib in Interface Builder and set identifier property and use this same string as reuseIdentifier while calling dequeueReusableCellWithIdentifier.

2) Pass reuseIdentifier in constructor of you nib file and then call its base constructor there which takes style and identifier as arguments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜