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
593 views
in Technique[技术] by (71.8m points)

iphone - custom uitableviewcells in storyboard

I think I got all the steps down but I must be missing something because I can't make a connection from the labels in the cell to the code.

Here's what I'm doing:

  1. set style of cell to custom
  2. dragging some labels onto the prototype cell.
  3. adding a new file to the project and making it a subclass of UITableViewCell
  4. in the identity inspector of the cell im trying to customize, I set its class to the new class I just created.
  5. TRY to control drag from the labels on the cell to the headerfile of the class I just created to setup an IBOutlet, but it won't let me.

What am I missing?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Declare the label as a property in the custom cell class. In the table view controller, alloc or dequeue the cell as your custom type, not as UITableViewCell. In the Xcode storyboard, control drag from the cell itself (for example, the far bottom right corner) to the label that is in the cell to connect the outlet.


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

...