ios – 如何在Swift中删除左侧的UITableView偏移量

栏目: Swift · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/24748025/how-to-remove-uitableview-offset-on-the-left-in-swift

我找到了一些问题和答案来删除ios7中UITableViews的偏移量,即这里的这个

How to fix UITableView separator on iOS 7?

我想知道是否有人遇到了正确的功能来删除插入边距.在objective-c中类似于这个答案的东西

if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [tableView setSeparatorInset:UIEdgeInsetsZero];
}

就像Objective-C示例一样,但转换为swift.我自己遇到了一些麻烦.如果您在UITableViewController中执行此代码,则此代码在UITableView中工作,您可以将self.tableView替换为self:

// iOS 7
if(self.respondsToSelector(Selector("setSeparatorInset:"))){
    self.separatorInset = UIEdgeInsetsZero
}

// iOS 8
if(self.respondsToSelector(Selector("setLayoutMargins:"))){
    self.layoutMargins = UIEdgeInsetsZero;
}

对于单元格(仅限iOS 8),将以下代码放在以下函数中:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)

获取单元格,并设置以下属性:

// iOS 8
if(cell.respondsToSelector(Selector("setLayoutMargins:"))){
    cell.layoutMargins = UIEdgeInsetsZero;
}

翻译自:https://stackoverflow.com/questions/24748025/how-to-remove-uitableview-offset-on-the-left-in-swift


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Text Processing in Python

Text Processing in Python

David Mertz / Addison-Wesley Professional / 2003-6-12 / USD 54.99

Text Processing in Python describes techniques for manipulation of text using the Python programming language. At the broadest level, text processing is simply taking textual information and doing som......一起来看看 《Text Processing in Python》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器