我使用 Storyboard创建了一个自定义 UITableViewCell
。
我是这样加载的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HJAddCell *cell = [tableView dequeueReusableCellWithIdentifier:@"addCell"];
// setting properties of cell
return cell;
}
现在我需要在初始化期间以编程方式添加更多自定义。但问题是在我的HJAddCell
中,init
方法没有被调用。我应该怎么做才能调用 init
方法,或者是否有任何其他方法可以在初始化时以最小的努力向自定义单元类添加更多自定义代码。
更新:我需要为 UILabel 添加边框。我在 Storyboard 中找不到任何东西可以做到这一点。
最佳答案
UIView 有两个 designated initializers : initWithFrame:
和 initWithCoder:
。 initWithCoder:
如果 View 是从 nib/storyboard 加载的,则使用 initWithFrame
- 如果 View 是以编程方式创建的。
关于iphone - 自定义 UITableViewCell 初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12710235/