解决UITableView分割线距左边有距离的办法xcode6

今天作项目时对比UI图忽然发现本身的cell左边的线距离屏幕左边有必定距离,左边的坐标已是0了,若是不想动坐标又解决此问题的话能够看看下面的方法
table

解决UITableView分割线距左边有距离的办法,有须要的朋友能够参考下。select

 

咱们在使用tableview时会发现分割线的左边会短一些,一般能够使用setSeparatorInset:UIEdgeInsetsZero 来解决。可是升级到XCode6以后,在iOS8里发现没有效果。下面给出解决办法:方法

首先在viewDidLoad方法中加上以下代码:项目

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {tab

[self.tableView setSeparatorInset:UIEdgeInsetsZero];tableview

}view

if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {升级

[self.tableView setLayoutMargins:UIEdgeInsetsZero];vi

}分割

而后在willDisplayCell方法中加入以下代码:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

[cell setSeparatorInset:UIEdgeInsetsZero];

}

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

[cell setLayoutMargins:UIEdgeInsetsZero];

}

}

这样就能够正常显示了。

相关文章
相关标签/搜索