故事板和表格视图部分

发布于 2024-12-28 21:02:55 字数 516 浏览 7 评论 0原文

我注意到,在故事板中,当从库中拖出表视图对象时,您还有机会配置表视图部分和许多其他选项。例如,如果内容是静态单元格或动态原型等。

下面是 Interface Builder 中的表视图(.storyboard 文件):

Storyboard

下面是表格视图在.xib 文件:

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):

Storyboard

and here's how the Table View looks like in a .xib file:

XIB

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唯憾梦倾城 2025-01-04 21:02:55

无论哪种方式都可以完成。我更喜欢在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文