我在我的项目中创建了一个自定义UITableViewCell
,我使用.xib文件创建了这个设置的几个图像:
这是我的主要细胞,所选细胞和所述细胞的背景的图像。 这是Main Cell的链接。
所以到目前为止我知道这部分工作正常。
这是我得到的错误:
我以为是因为我试图在tableview之前加载单元格?但我的表视图在rootViewController执行时加载,因此不能...这是我的表视图代码(相关代码):
键:
GroupCell
=我的.h,.m,.xib文件的名称。
objectivenameArray
=使用NSMutableArray执行的NSString收集服务器数据的数组。
- (NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [objectivenameArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"cellID";
GroupCell *groupCell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (groupCell == nil) {
groupCell = [[GroupCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
groupCell.objectiveLabel.text = [objectivenameArray objectAtIndex:indexPath.row];
return groupCell;
}
我将补充说我正在使用服务器API AFNetworking,但这应该会产生问题,因为我的所有URLData都已正确链接。当我尝试加载自定义单元格时,问题就开始出现了。有任何想法吗?提前谢谢!
答案 0 :(得分:1)
回答我自己的问题;我收到的错误是因为我仍然在我的自定义单元格.xib文件上打开了自动布局功能。
答案 1 :(得分:0)
看起来错误信息非常清楚。
GroupCell的-layoutSubviews实现需要调用super
我假设您已在GroupCell中覆盖了layoutSubviews,并且您忘记将[super layoutSubviews]放在方法的开头。把它放进去,错误应该消失。