How do I create a custom UITableViewCell with nib

2019-04-30 15:11发布

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:

New File

enter image description here

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?

3条回答
对你真心纯属浪费
2楼-- · 2019-04-30 15:32

Javy, 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.

You are done.

查看更多
看我几分像从前
3楼-- · 2019-04-30 15:39

This blog post describes, how to add it manually.

edit
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.

查看更多
乱世女痞
4楼-- · 2019-04-30 15:42

This link may bel helpful to you.

查看更多
登录 后发表回答