ios - 在 Interface Builder 中的 UITableViewCells 中定位 UIControl

标签 ios iphone xcode interface-builder

所以我在 .xib 文件中有一个 UITableView 。这就是其中的全部内容。

cellForRowAtIndexPath 方法中,我使用自定义 UITableViewCell。 IB 中的 UITableViewCell 宽度为 320

我放入了一个 UISegmentedControl 并将其按照蓝色引导线居中。当我在弹出窗口中显示表格时,UITableViewCell 中的 UISegmentedControl 未居中。就像 UITableViewCell 被切断一样。我附上了一张图片。

我是否忘记了事物的大小?我还有另一个 4 分段控件,尽管分段控件显示在 UITableViewCell 中,但它被切断了。我的 contenstSizeForPopover 宽度也设置为 320

enter image description here

最佳答案

当您将单元格放入组 TableView 中时,单元格会将其内容区域缩小 20 磅,以允许表格边框/背景区域。这就是你的控制被切断的原因。

您可以将控件设置为具有灵活的宽度:

autosizing with flexible width

但在设计单元格布局时,您必须牢记调整大小。

关于ios - 在 Interface Builder 中的 UITableViewCells 中定位 UIControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7935615/

相关文章:

ios - 如何以编程方式在 UINavigationController 中显示第二个模态 ViewController

ios - Bundle.main.path(forResource :ofType:inDirectory:) returns nil

ios - 午夜后刷新iOS UIDatePicker的内部状态

iOS 8 键盘扩展按钮不显示

objective-c - 是否可以以非编程方式查看核心数据表中的条目?

objective-c - 如何使用 MainMenu.xib 中的 View ?

ios - 如何处理 Sqlite 数据库在 iOS 中被锁定?

objective-c - 拆除 UIViewController 时是否总是调用 viewDidUnload 和 dealloc?

iphone - NSJSONSerialization 中没有返回

ios - 通用 2D 游戏 Assets 和绝对节点定位