IOS8 TableView的分割线

在IOS8 中,无法再通过Storyboard设置让tableView的分割线与左边界对齐了,网上有很多人提供了解决办法,在IOS8及8.1的版本中可以使用,但是在8.3的版本又不行了,8.3的版本中,需要如下设置

 

在cellForIndexPath里,添加:

if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        [cell setPreservesSuperviewLayoutMargins:NO];
    }

重写TableView的代理

- (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];
}

一定是Cell!亲测这里写成tableView是没有效果的

posted @ 2015-05-15 09:26  yybz  阅读(239)  评论(0)    收藏  举报