本文转自:http://my.oschina.net/zhuzhu1223/blog/474529?fromerr=VQUNYpha 感谢原创作者
欢迎大家学习探讨
1. 解决UITableView分割线距左边有距离的问题
我们在使用tableview时会发现分割线的左边会短一些,通常可以使用setSeparatorInset:UIEdgeInsetsZero 来解决。但是升级到XCode6之后,在iOS8里发现没有效果。下面给出解决办法:
viewDidLoad方法和willDisplayCell中加上如下代码:
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) { [self.tableView setSeparatorInset:UIEdgeInsetsZero]; } if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) { [self.tableView setLayoutMargins:UIEdgeInsetsZero]; }
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)])
{
[cell setPreservesSuperviewLayoutMargins:NO];
}