相关疑难解决方法(0)

iOS 8自动高度单元在第一次加载时不正确的高度

我有一个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)

还有其他人经历过这个吗?

uitableview ios autolayout ios8

23
推荐指数
2
解决办法
9251
查看次数

如何在uitableviewcell中添加uiview

希望你们所有人都没事.我的申请中有一点问题.我有自定义单元格的tableview.在我的定制单元课上,我做了一个uiview

    UIView* cellView = [[UIView alloc] initWithFrame:self.contentView.frame];
    cellView.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:cellView];
Run Code Online (Sandbox Code Playgroud)
问题是uiview不适合我的细胞框架.Cellforrow如下:

- (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和高度相同但是失败了.需要您宝贵的建议和想法.非常感谢.

objective-c uitableview

3
推荐指数
1
解决办法
2782
查看次数

标签 统计

uitableview ×2

autolayout ×1

ios ×1

ios8 ×1

objective-c ×1