iOS 11 UiTableViewCell 位置问题
iOS 11 UiTableViewCell Location issue
我有一个接一个的四个UITableView cell。在 iOS 10.3 中,第一个单元格紧跟在状态栏之后,但在 iOS 11 中,状态栏和第一个单元格之间有一些 space。
可能是新引进的原因contentInsetAdjustmentBehavior
默认设置为 .automatic
,但可以将其禁用,切换为 .never
:
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.never
}
我在 iOS 11 中遇到了类似的问题。空白是页眉和页脚。在 iOS < 11 中,将 heightForHeaderInSection
和 heightForFooterInSection
设置为 CGFLOAT_MIN
就足够了。在 iOS 11 中,我还必须在 viewForHeaderInSection
和 viewForFooterInSection
.
中 return nil
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection: (NSInteger)section {
return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
我有一个接一个的四个UITableView cell。在 iOS 10.3 中,第一个单元格紧跟在状态栏之后,但在 iOS 11 中,状态栏和第一个单元格之间有一些 space。
可能是新引进的原因contentInsetAdjustmentBehavior
默认设置为 .automatic
,但可以将其禁用,切换为 .never
:
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.never
}
我在 iOS 11 中遇到了类似的问题。空白是页眉和页脚。在 iOS < 11 中,将 heightForHeaderInSection
和 heightForFooterInSection
设置为 CGFLOAT_MIN
就足够了。在 iOS 11 中,我还必须在 viewForHeaderInSection
和 viewForFooterInSection
.
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection: (NSInteger)section {
return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}