在默认配置中 ,UITableView的Cell之间的Seperator左边总是空出一块,即使在Storyboard中设置为0 ,也没有效果

需要在代码中进行配置,在ViewController中实现如下方法

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

// Remove seperator inset

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

[cell setSeparatorInset:UIEdgeInsetsZero];

}

// Prevent the cell from inheriting the Table View's margin settings

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

[cell setPreservesSuperviewLayoutMargins:NO];

}

// Explictly set your cell's layout margins

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

[cell setLayoutMargins:UIEdgeInsetsZero];

}

}

如果所有的界面都是如此风格,也可以通过UIAppearance 统一配置

// iOS 7:

[[UITableView appearance] setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];

[[UITableView appearance] setSeparatorInset:UIEdgeInsetsZero];

[[UITableViewCell appearance] setSeparatorInset:UIEdgeInsetsZero];

// iOS 8:

if ([UITableView instancesRespondToSelector:@selector(setLayoutMargins:)]) {

[[UITableView appearance] setLayoutMargins:UIEdgeInsetsZero];

[[UITableViewCell appearance] setLayoutMargins:UIEdgeInsetsZero];

[[UITableViewCell appearance] setPreservesSuperviewLayoutMargins:NO];

}

原文链接:http://stackoverflow.com/questions/25770119/ios-8-uitableview-separator-inset-0-not-working

自定义UITableView的Seperator的更多相关文章

  1. (Ios 实战) 自定义UITableView

    自定义UITableView 分成两个部分 1 自定义UITableViewCell 继承UITableViewCell,同时提供接口,根据当前的数据,现实View 2  在UITableView中实 ...

  2. 自定义UITableView各种函数

    转自:http://blog.sina.com.cn/s/blog_7e3132ca0100wyls.html 在XCode对应头文件中修改该类所继承的父类: 在对应的.m文件中添加如下代码: 这样就 ...

  3. [Xcode 实际操作]五、使用表格-(8)自定义UITableView单元格Accessory样式(附件图标)

    目录:[Swift]Xcode实际操作 本文将演示如何自定义单元格的附件图标. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit //首先添 ...

  4. 自定义UITableview自带侧滑删除按钮样式 by 徐

    效果如下: 实现原理: 1.打开tableview自带的侧滑删除功能 核心代码: 1 -(void)tableView:(UITableView *)tableView commitEditingSt ...

  5. Objective-c——UI基础开发第七天(自定义UITableView)

    一.梗概: 1.自定义:headerView,footerVie,Cell等 2.双模型(遵循单一原则,类或模型实现的功能尽量单一) 3.计算文本的方法(针对不同文本内容而设置的宽高等) 4.设置fo ...

  6. iOS开发之自定义UITableView的cell

    系统默认的UITableViewCell的每行都有横线(分隔符),就算没有数据也是如此,有时候我们想只在有数据的地方有下划线,可以去除下划线,然后在awarkFromNid方法中使用addsubvie ...

  7. ios 自定义UITableView中分组的标题sectionview

    //Section的标题栏高度 -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)sec ...

  8. iOS开发——高级UI&带你玩转UITableView

    带你玩装UITableView 在实际iOS开发中UITableView是使用最多,也是最重要的一个控件,如果你不会用它,那别说什么大神了,菜鸟都不如. 其实关于UItableView事非常简单的,实 ...

  9. IOS7学习之路一(新UI之自定义UITableViewCell)

    ios7 新升级之后界面有了很大的变化,xcode模拟器去掉了手机边框和home键,如果想回到主页面,可以按住shift+comment+r键.废话少说先展示一下新UI下UItableView设置为G ...

随机推荐

  1. Asp.Net MVC Ajax

    将ASP.NET MVC中的form提交改为ajax提交 在ASP.NET MVC视图中通过 @using (Html.BeginForm()) 产生的是form表单提交代码,可以用javascrip ...

  2. Sql解锁 数据库死锁检测

    USE [DataBaseName]GO/****** Object:  StoredProcedure [dbo].[sp_check_deadlock]    Script Date: 07/04 ...

  3. iOS崩溃报告获取二

    // // JKExceptionHandler.h // JKExceptionHandler // // Created by Jack on 16/9/7. // Copyright © 201 ...

  4. [C#][转]与MySql连接访问

    using System;using System.Configuration;using MySql.Data.MySqlClient;/// <summary>/// TestDate ...

  5. [转]setTimeout() 函数未定义错误

    用 setTimeout("showMe()",1000) 时出现 showMe is not defined 错误.这是由于showMe() 函数不在 setTimeout 调用 ...

  6. WampServer修改MySQL密码

    WampServer安装后密码是空的,需要设置一下 一般有两种方式: 一是通过phpMyAdmin直接修改: 二是使用WAMP的MySql控制台修改. 第一种: ①在phpMyAdmin界面中点击[用 ...

  7. hdoj (1162) 最小生成树

    Problem B Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Sub ...

  8. 3D math primer for graphics and game development

    三角网格(Triangle Mesh) 最简单的情形,多边形网格不过是一个多边形列表:三角网格就是全部由三角形组成的多边形网格.多边形和三角网格在图形学和建模中广泛使用,用来模拟复杂物体的表面,如建筑 ...

  9. 关于安卓启动eclipse错误:找不到元素‘d:devices'的声明

    可以把C:\Documents and Settings\Administrator\.android\devices.xml这个文件删除, 再把sdk里面tools\lib下的这个文件拷贝到你删除的 ...

  10. 看es6 字符串新方法有感

    'x'.repeat(3) // "xxx" 'hello'.repeat(2) // "hellohello" 'na'.repeat(0) // " ...