Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

ios - initwithstyle:reuseIdentifier: not called

I'm creating my own custom UITableViewCell to use as the backend of a prototype cell. In my class I override the initwithstyle:reuseIdentifier: method to do some custom initialization, but my initializer is not called. I have a break point on the first line inside of it, as well as a break point on dequeueResusableCellWithIdentifier:. The dequeueResusableCellWithIdentifier: method is called, and it returns a initilized cell, but the break point in initwithstyle:reuseIdentifier: is not reached. Any help would be great.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If your cell is being created from a storyboard prototype (which you have declared as the custom class in IB) then it won't be created with initWithStyle... but initWithCoder: instead, like any other object loaded from a nib. If you have any setup code, it should be in there or in awakeFromNib.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...