iphone - 自定义 UITableViewCell 初始化

标签 iphone objective-c ios uitableview

我使用 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/

相关文章:

iPhone - 无法将 int 放入 UIButton

ios - Quickblox - 获取用户 friend 的头像并显示在 UITableView 中

带有 Tabbar 的 iOS7 自动布局与 UIScrollView 和可缩放的 UIImageView 不工作

ios - IBOutlet 创建的不同方法

javascript - 滚动 UI 时 UI 未更新

iphone - 如何在 iOS 设备上将 mov 转换为 mp4

ios - 执行 segue 时哪个对象是发送者?

objective-c - 简单的 slider 应用程序,快速提问

objective-c - UITableViewCell 未接收指定索引路径处的单元格对象

iphone - 排除 mapkit 性能故障