How do I create a custom UITableViewCell with nib in Xcode 4?

ⅰ亾dé卋堺 提交于 2019-12-07 06:16:58

问题


In Xcode 3, I could elect to make a nib when creating a table view cell subclass. In Xcode 4, it only makes the h / m files.

How do I make the subclass with a xib file?

Edit: see screen shots below:

EDIT: Additionally, is there any way to create the UITableViewCell nib automatically, along with the h and m files, all pre-wired and ready to edit?


回答1:


This blog post describes, how to add it manually.

in iOS4+, the line

NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@”CustomCell” owner:self options:nil];

can be replaced by a more efficient nib handling via UINib.
see this blog post how to do it, and how to stay backwards compatible.




回答2:


As I understood you already have .h/.m files and you are missing the view (nib).

  1. Please select new file, select "User Interface" category and empty in sub category.
  2. Once your nib is created, drag and drop the UITableViewCell on the screen.
  3. Set the class as First Responder.


来源:https://stackoverflow.com/questions/8291518/how-do-i-create-a-custom-uitableviewcell-with-nib-in-xcode-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!