首页 > 移动平台 > 详细

IOS8 TableView的分割线

时间:2015-05-15 10:20:56      阅读:180      评论:0      收藏:0      [点我收藏+]

在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是没有效果的

IOS8 TableView的分割线

原文:http://www.cnblogs.com/yybz/p/4505098.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!