首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cell.contentView.constraints.count =0

cell.contentView.constraints.count =0
EN

Stack Overflow用户
提问于 2015-09-14 22:11:42
回答 1查看 99关注 0票数 1

使用情节提要为单元格创建约束,但cell.contentView.constraints.count0

代码语言:javascript
复制
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TestCell *cell = [tableView dequeueReusableCellWithIdentifier:@"testCell"];
    cell.fd_enforceFrameLayout = NO;// why equals to 0
    cell.item = self.items[indexPath.row];
    NSLog(@"%ld", cell.contentView.constraints.count);
    return cell;
}
EN

回答 1

Stack Overflow用户

发布于 2015-09-16 17:22:01

尝试使用dequeuReusableCellWithIdentfierforIndexPath版本。非indexPath版本返回一个没有size类的单元格,因为该单元格不是表的一部分。forIndexPath版本确实返回了一个具有size类的单元格,因为它从包含该单元格的表中继承了它。

代码语言:javascript
复制
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TestCell *cell = [tableView dequeueReusableCellWithIdentifier:@"testCell" forIndexPath:indexPath];
    cell.fd_enforceFrameLayout = NO;// why equals to 0
    cell.item = self.items[indexPath.row];
    NSLog(@"%ld", cell.contentView.constraints.count);
    return cell;
}

然后,NSLog应该输出与您运行的size类的约束数量相匹配的count值。将size类作为调试的一部分打印出来是值得的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32567009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档