美文网首页
UITableViewController的cell分割线显示完

UITableViewController的cell分割线显示完

作者: 丫丫_dyl | 来源:发表于2016-06-24 17:12 被阅读387次

一、如果是通过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];

}

}

   

相关文章

网友评论

      本文标题:UITableViewController的cell分割线显示完

      本文链接:https://www.haomeiwen.com/subject/udjgdttx.html