#pragma mark - TableView Optional Methods - (void)tableView:(UITableView *)tableView didSelectRowAt

来源:互联网 发布:高端的社交软件 编辑:程序博客网 时间:2024/06/15 02:58

在iOS 7 中,我们可能会这样设置UItableview,把分割线右移的问题解决掉。

#ifdef __IPHONE_7_0

    if ([tableViewProj respondsToSelector:@selector(separatorInset)]) {

        [tableViewProj setSeparatorInset:UIEdgeInsetsZero];

    }

#endif

但是在iOS8中就没有这么灵了。解决办法是:

首先在viewDidLoad方法加入以下代码:

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

[tableViewProj   setSeparatorInset:UIEdgeInsetsZero];

}

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

[tableViewProj setLayoutMargins:UIEdgeInsetsZero];

}

然后在UITableView的代理方法中加入以下代码

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

}

}

0 0