开发者

Strange issue with UITableViewCell: UILabel turns into something else?

I got this strange issue while working with iPhone SDK 3.1.2.

My UITableViewCell contains 3 UILabel, each of which is assigned a numeric tag from 1 to 3.

http://img.skitch.com/20100109-gdg9f57999gne3psqmmb3y4nb1.png

The problem is with the first UILabel (highlighted in the above screenshot): I am unable to set its text to anything. Even NSLog its content gives me a (nul开发者_JS百科l).

What's interesting is that when I tried to print the UILabel's class name, I got UITableViewCell instead.

http://img.skitch.com/20100110-7jfgipbiskbc9xm68pt3mqfqi.png

Changing this particular UILabel's tag to other number (e.g. 4) makes it work properly. How strange.

Anyone got an idea?


You must be checking into the cell.contentView not the view itself. :)


Since you're creating the cell in Interface Builder, I wouldn't use the tag thing anyway. I'd just subclass UITableViewCell as MyCell or something, change your table cell's class to MyCell, then declare some IBOutlets in MyCell that you can connect the subviews to. That also allows you to define some convenience methods/properties for the cell as well.

Then you can forget the tags and just do myCellInstance.nameLabel.text = @"Joebob Briggs" or whatever.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜