故事板和表格视图部分
我注意到,在故事板中,当从库中拖出表视图对象时,您还有机会配置表视图部分和许多其他选项。例如,如果内容是静态单元格或动态原型等。
下面是 Interface Builder 中的表视图(.storyboard 文件):
下面是表格视图在.xib 文件:
所以我的问题是 - 是否可以使用 Interface Builder 在 .xib 文件中配置/样式化(将按钮、图像等拖动到单元格中)表视图,或者只能以编程方式完成?
I've noticed that in Storyboards, when dragging out a Table View object from the Library, you also get a chance to configure table view sections, and bunch of other options. For example, if the content is going to be static cells or dynamic prototypes, etc.
Here's a look at the Table View in Interface Builder (.storyboard file):
and here's how the Table View looks like in a .xib file:
So my question is - is it possible to configure/style (drag buttons, images, etc. into cells) a table view in a .xib file using Interface Builder or it can only be done programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论哪种方式都可以完成。我更喜欢在 IB 中进行,因为当您可以看到自己在做什么时,布局会容易得多。对于动态原型,您只需设计一个单元格,内容将填充在 cellForRowAtIndexPath 方法中。使用静态单元格表格视图,您可以设计整个事物(许多部分和许多行)。静态单元格表视图的要求是该类必须是 UITableViewController 类型,而对于动态原型,它可以是 UITableViewController 或(我更喜欢灵活性)带有 UITableView 的 UIViewController。
提示 - 如果这是一个静态单元格表格视图,并且您只设计了一个充满部分和行的屏幕,请务必关闭表格视图的滚动。
Can be done either way. I prefer doing it in IB as the layout is much easier when you can see what you are doing. For dynamic prototypes, you only design a single cell and the contents will be populated in the cellForRowAtIndexPath method. With a Static Cell tableview, you can design the whole thing (many sections and many rows). The requirement for a Static Cell tableview is that the class HAS to be of type UITableViewController, while for Dynamic Prototypes, it can be either a UITableViewController or (my preference for more flexibility) a UIViewController with a UITableView.
Hint - if this is a Static cell tableview and you only design a screen full of sections and rows, be sure to turn off scrolling for the tableview.