我正在用XIB的tableview单元创建一个tableview。
当我将tableview单元格与Tableview集成并运行时,它显示不完美,它显示了覆盖。
图片是
代码是
static NSString *cellIdentifier =@"DiscussionTableViewCell";
DiscussionTableViewCell *cell = (DiscussionTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"DiscussionTableViewCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
// [cell.btnConnect addTarget:self action:@selector(btnUserConnectClick:) forControlEvents:UIControlEventTouchUpInside];
// [cell.btnNotnow addTarget:self action:@selector(btnNotNowClick:) forControlEvents:UIControlEventTouchUpInside];
self.cellHeight += cell.frame.size.height;
NSLog(@"Cell height is %f",self.cellHeight);
最佳答案
请按照以下步骤操作:
numberOfLines
属性更改为零func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat{
return 55
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{
return UITableViewAutomaticDimension
}
现在运行您的项目并检查。
预期输出:
关于ios - Tableview单元格从底部被覆盖,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43108704/