开发者

is it necessary to have instance variables in a UITableViewCell subclass?

开发者 https://www.devze.com 2023-02-18 16:52 出处:网络
Question - Is it necessary to have subview (e.g. UILabel) instance variables in a UITableViewCell subclass?

Question - Is it necessary to have subview (e.g. UILabel) instance variables in a UITableViewCell subclass?

The alternative I am thinking of being to construct say the UILabels you want for your custom UITableViewCell subclass when you create it, assign them to the content view (e.g. [self.contentView addSubview:label_1]), and then release the UILabel (e.g. [label_1 release]).

So is it the case the only开发者_StackOverflow社区 reason you need to keep the labels as instance variables (declared in the header) of the UITableViewCell subclass, so that you can grab them more easily to configure/make changes to them later. That is as opposed to having to find through by looking them up directly in the contentView via their tag values?

thanks


it is a convenience, but one worth sticking with. if you call viewWithTag everytime something needs to be changed/redrawn it can be less efficient than just using the pointer stored in the stack, as this would have to be recalculated each time.

0

精彩评论

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