我有一个iOS 8应用程序,我有一个搜索结果页面,每个单元格根据某个标签的高度进行自动调整.但是,在视图首次加载后,显示的单元格不会自动调整大小.向下滚动后面的单元格大小正确.我在故事板中连接了自动布局约束.我在viewDidLoad中有以下代码.
- (void)viewDidLoad {
[super viewDidLoad];
//configure tableView so that we use autolayout enabled row heights
self.tableView.estimatedRowHeight = 68;
self.tableView.rowHeight = UITableViewAutomaticDimension;
}
Run Code Online (Sandbox Code Playgroud)
还有其他人经历过这个吗?
希望你们所有人都没事.我的申请中有一点问题.我有自定义单元格的tableview.在我的定制单元课上,我做了一个uiview
UIView* cellView = [[UIView alloc] initWithFrame:self.contentView.frame];
cellView.backgroundColor = [UIColor grayColor];
[self.contentView addSubview:cellView];Run Code Online (Sandbox Code Playgroud)
- (SummaryViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cell";
SummaryViewCell *cell = (SummaryViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil)
{
cell = [[SummaryViewCell alloc] init];
}
cell.backgroundColor = [UIColor blueColor];
return cell;
}Run Code Online (Sandbox Code Playgroud)
我已经尝试过initWithFrame:self.contentView.frame]但是同样的问题发生了(uiview出现在单元格中,但只覆盖了一半的单元格),我也尝试过cellView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self. frame.size.width和高度相同但是失败了.需要您宝贵的建议和想法.非常感谢.