UITableViewController的cell分割线显示完整的处理方法

一、如果是通过storyboard创建的静态cell,显示完整cellf分割线的方法如下:

首先选中cell,Focus Style选择Custom,下面Indentation的值设置为0,还需要设置另外一个地方为Layout Margins 选择Explicit,并将下面的值设置为0,才可以成功的解决问题。图如下所示:


二、代码创建的cell,显示完整的分割线如下的代码:

      -(void)viewDidLayoutSubviews {

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

[self.tableView setSeparatorInset:UIEdgeInsetsZero];

}

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

[self.tableView setLayoutMargins:UIEdgeInsetsZero];

}

}

-(void)tableView:(UITableView *)tableView

willDisplayCell:(UITableViewCell     *)cell

forRowAtIndexPath:(NSIndexPath *)indexPat{

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

[cell setLayoutMargins:UIEdgeInsetsZero];

}

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

[cell setSeparatorInset:UIEdgeInsetsZero];

}

}

   

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 版权声明:未经本人允许,禁止转载. iOS 7之后,tableView的分割线左边距默认设置为15,如图 iOS ...
    萧雪痕阅读 4,317评论 0 6
  • 1、禁止手机睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa阅读 1,141评论 1 6
  • 今天试了一下临摹萌萌哒的东西…效果还算是不错~嘿嘿嘿,给亲亲们看看,明天会在公众号出教程。喜欢的亲亲可以去看。
    悦离阅读 164评论 5 3
  • - 1 - 我站在父亲身边,看着他把鲷鱼裹上面包屑,一块块地放入翻腾的油锅里。 这些鱼曾经自由地在深海里遨游,我想...
    公主悦读阅读 561评论 0 4
  • 有友是当今所谓的营销策划大师,在吃一碗面的当口,就看他写出哲理性的人生终结:自曰“十句废话” 十句废话: 1,读书...
    剪辑life阅读 292评论 0 0