ios - TableView ContentInset 不缩小单元格宽度/向 TableView 内容添加水平填充

标签 ios objective-c uitableview ios7 padding

我想要一个全屏的 UITableView。但是 UITableView 的内容应该在左边和右边有一个填充。

所以我尝试设置ContentInset。但现在单元格与 UITableView 一样宽,并且 UITableView 水平滚动。

有没有办法说 UITableView 内容的宽度应该被水平内容插入变窄?还是我必须向所有单元格和页眉/页脚 View 添加填充?

我不想缩小 TableView 本身,因为滚动指示器应该位于屏幕的右侧而不是中间。 这里(How to set the width of a cell in a UITableView in grouped style)建议的解决方案似乎不像我喜欢的那样通用,因为单元格和页眉和页脚 View 必须知道填充(至少要维护 3 个位置而不是一个)

最佳答案

I don't want to narrow the table view itself, because the scroll indicator should stay at the right side of the screen and not in the middle.

这让你开心?

_tableView.clipsToBounds = NO;
_tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, -30.f);

如果您不喜欢 clipsToBounds = NO 效果,您可以将 tableView 嵌入到 clipsToBounds = YES 的容器 View 中。

关于ios - TableView ContentInset 不缩小单元格宽度/向 TableView 内容添加水平填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24882525/

相关文章:

ios - QuickBlox 聊天 : can't perform video call

objective-c - 如何使用 Xcode 4 绑定(bind)到 Cocoa 中的自定义 View ?

iphone - 当你在 iPhone 上输入完文字后,如何关闭键盘?

ios - 在 Core Data 中更改 NSOrderedSet 顺序的尝试和磨难

xcode - UITableViewCell 自定义布局和边框 UIBubble

ios - Google Analytics - 谁能解释一下维度和指标?

ios - 正在下载文件时 UIlabel 文本未更新

c# - Xamarin Forms MVVM 与实际模型

ios - 如何保存带有混响效果的录制音频

ios - 如何知道是否使用 MGSwipeTableCell 删除了所有单元格