iOS11 最简单的适配----tableView,backBarButtonItem相关问题解决方案

tableView跑偏的解决方法:

self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
if (@available(iOS 11.0, *)) {
    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    self.tableView.scrollIndicatorInsets = self.tableView.contentInset;
}

tableView 如果是Gruop类型的话,section之间的间距莫名奇妙的,而且tableView顶部也有一片空空的。把这些代理方法写上。运行起来看看效果吧,原因就是如果设置了区头高度和区尾高度,默认会认为你有区头和区尾,所以我们要初始化一个区头或区尾来解决

- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section{
  return10;
}
- (CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section{
  return0.1;
}
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section {
  return[[UIViewalloc]init];
}
- (UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section {
  return[[UIViewalloc]init];
}

系统自带返回按钮莫名偏移

[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"返回按钮图片.png"]];

[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"返回按钮图片.png"]];

设置后发现,怎么还会有自带的一个title呢、不想要的话,就在根视图的init方法中写上下面的一段话就完美解决了。

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:nil action:nil];//既然不想要title,设置空字符串不就可以了么。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容