码迷,mamicode.com
首页 > 其他好文 > 详细

tableView 短剪线离开15像素问题

时间:2015-09-10 22:27:15      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

ios7于,UITableViewCell左将默认15空白像素。

建立setSeparatorInset:UIEdgeInsetsZero 空白可以去除。

ios8中。setSeparatorInset:UIEdgeInsetsZero 的设置已经不起作用了。

以下是解决的方法,首先在viewDidLoad方法增加以下代码:

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

{

     [self.tableView setSeparatorInset:UIEdgeInsetsZero];

}

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

 {

     [self.tableView 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];

       }

}

 

版权声明:本文博主原创文章。博客,未经同意不得转载。

tableView 短剪线离开15像素问题

标签:

原文地址:http://www.cnblogs.com/bhlsheji/p/4799149.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!