UITableView的默认的cell的分割线左边没有顶满,而右边却顶满了。这样显示很难看。我需要让其左右两边都是未顶满状态,距离是20像素

// code1
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(, , , )];
} // code2
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsMake(, , , )];
}

添加UITableView的一个代理方法:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)])
{
[cell setSeparatorInset:UIEdgeInsetsMake(, , , )];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)])
{
[cell setLayoutMargins:UIEdgeInsetsMake(, , , )];
}
}

ode1处代码: 
定制cell分割线的frame

code2处代码: 
-layoutMargins returns a set of insets from the edge of the view’s bounds that denote a default spacing for laying out content. 
If preservesSuperviewLayoutMargins is YES, margins cascade down the view tree, adjusting for geometry offsets, so that setting the left value of layoutMargins on a superview will affect the left value of layoutMargins for subviews positioned close to the left edge of their superview’s bounds 
If your view subclass uses layoutMargins in its layout or drawing, override -layoutMarginsDidChange in order to refresh your view if the margins change.

UITableView的分割线长短的控制的更多相关文章

  1. iOS UITableView的分割线短15像素,移动到最左边的方法(iOS8)

    有好几个朋友问我ios 分割线端了一些 如何解决,于是我就写一篇博客吧.为什么我说是少了15像素呢?首先我们拖拽一个默认的tableview 控件! 看下xcode5 面板的inspector(检查器 ...

  2. UITableView的分割线不满屏的解决方法

    #pragma -mark 以下2个方法,解决分割线不满屏问题 -(void)viewDidLayoutSubviews { if ([tableView respondsToSelector:@se ...

  3. 45.UITableView去除分割线

    1.去除所有的分割线 table.separatorStyle = UITableViewCellSelectionStyleNone; 2.去除指定某一行的分割线 cell.separatorIns ...

  4. iOS中UITableView分割线左侧顶齐

    iOS 7开始UITableView的分割线不在从左侧边界开始了,而是默认空出了一段距离. 如果想要使用默认的分割线而且还要从左侧边界开始的话,有几种解决方式: 1.在tableView的代理方法中设 ...

  5. 你真的会用UITableView嘛

    UITableView是工程开发中最经常使用到的UI控件,但是你真的了解它嘛,这里记录几点有用的但你可能并不知道的. 当我们的数据未能显示满一屏幕的时候,UITableView会显示多余的横线,这个时 ...

  6. TableViewCell自定义分割线

    产品设计的要求cell的分割线长度不用是整个屏幕宽,并且设计要求分割线为2px(两条),上下不同色. 实现如下: UITableView中将分割线样式改为None tableView.separato ...

  7. 【转】 UITableView 的indexPath

    原文:http://blog.csdn.net/mengtnt/article/details/6733691 前面说过了viewController的一些基本注意事项.这里针对不同的viewCont ...

  8. UITableView使用中的一些刁专问题总结

    tableview中cell的系统分隔线问题(分隔线顶满或者缩短) //tableview代理方法,设置系统cell的分隔线 -(void)tableView:(UITableView *)table ...

  9. iOS开发,UITableView相关问题

    第一条:UITableViewCell 内容的设置 //文本放到最后 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_dataArr.co ...

随机推荐

  1. ES6躬行记(11)——对象

    在第5篇中,讲解了多个对象字面量的改进,本节将重点介绍两个新增的静态方法,以及对象属性的重复处理和枚举顺序. 一.Object.is() 此方法用于判断两个值是否相同,内部实现了SameValue算法 ...

  2. MyBatis源码解析(八)——Type类型模块之TypeAliasRegistry(类型别名注册器)

    原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/6705769.html 1.回顾 前面几篇讲了数据源模块,这和之前的事务模块都是enviro ...

  3. docker常用命令2

    Docker作为一种开源的.优秀的容器化技术,目前受到越来越多公司的运用,下面是我工作中常用到的一些命令. 1.删除一个容器(删除之前先要停止该容器) docker stop 容器IDdocker r ...

  4. MySQL 索引与查询优化

    本文介绍一些优化 MySQL 索引设计和查询的建议.在进行优化工作前,请务必了解MySQL EXPLAIN命令: 查看执行计划 索引 索引在逻辑上是指从索引列(关键字)到数据的映射,通过索引可以快速的 ...

  5. [android] 保存联系人到系统通讯录

    对应着读联系人,把数据写进去,市场上的社交类应用经常会有这样的功能 向raw_contacts表中添加一个id 向data表里面添加对应的数据 获取ContentResolver对象,通过getCon ...

  6. D. GukiZ and Binary Operations(矩阵+二进制)

    D. GukiZ and Binary Operations   We all know that GukiZ often plays with arrays. Now he is thinking ...

  7. Flask 系列之 FlaskForm

    通过使用 FlaskForm ,可以方便快捷的实现表单处理. 说明 操作系统:Windows 10 Python 版本:3.7x 虚拟环境管理器:virtualenv 代码编辑器:VS Code 实验 ...

  8. datetime模块+calendar模块

    datetime: """ 模块中的类: datatime 同时有时间和日期 timedelta 主要用于计算时间的跨度 tzinfo 时区相关 time 只关注时间 d ...

  9. EF中更新操作 ID自增但不是主键 ;根据ViewModel更新实体的部分属性

    //ID自增但不是主键的情况 public int Update_join<TEntity>(TEntity entity) where TEntity : class { dbconte ...

  10. 配置安全域名https申请免费证书并配置nginx运行环境

    补全信息时选项 在这一步需要去查看进度,下载对应文件上传到对应站点根目录里按照要求建的隐藏类型的文件 如下图 讲证书文件按照下面操作 进行配置项配置https 如下 详情下载附件 server { l ...