ios - UI相关初始化代码UITableViewCell with Storyboard的最佳位置

标签 ios objective-c uitableview

应该在 UITableViewCell 的初始化时运行的 UI 相关代码的最佳位置是什么?子类? IE。

self.someLabel.backgroundColor = [UIColor DISBadgeRed];
self.anotherLabel.layer.cornerRadius = self.unseenMatchesLabel.frameHeight / 2;

背景
我使用 Storyboard ,所以指定的初始化程序 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier没有被调用并且在 initWithCoder: es 调用,UI 还没有为这些调用做好准备。

我可以从 cellForRow... 中调用的方法调用此代码但随后每次都会被调用。

最佳答案

你可以把它放在awakeFromNib Storyboard中的所有导出和 View 都将在调用时设置。

关于ios - UI相关初始化代码UITableViewCell with Storyboard的最佳位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29306346/

相关文章:

ios - iOS "Developer"角色可以创建/上传 Testflight 版本吗?

ios - 在 UITabBar 上查看

ios - 一起为 UITableView 框架和 contentOffset 设置动画

ios - 未从自定义 uitableviewcell 调用 prepareForSegue

ios - 在 pod install post_install 步骤中出现重复的 UUID 警告

ios - 在observeSingleEvent 中变量的值没有改变

objective-c - 刷新 UIViewController 的界面方向

objective-c - 错误 : 'archiver has finished; cannot encode anything more'

ios - 作为 XIB 的 TableViewCell 中的 Collection View

ios - 如何在 UITableView 中创建单行 View 分隔符