我在 iPhone 5s 屏幕尺寸中的行高为 80 px,但当表格出现在 iPhone 6+ 上时,它与 iPhone 5s 相同。我们可以使用自动布局
调整单元格的高宽比吗?
最佳答案
Autolayout
无法做到这一点。您应该以编程方式执行此操作,但这非常简单。
您必须从 UITableviewDelegate
实现一个“方法”:
- tableView:heightForRowAtIndexPath:
并根据设备屏幕高度设置单元格高度。例如:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UIScreen.mainScreen.bounds.size.height/7;
}
关于ios - 使用 Autolayout 时,单元格高度会随着设备高度的变化而变化吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32454662/