静态单元和动态原型之间有什么区别? [英] What's the difference between static cells and dynamic prototypes?
问题描述
我想知道在 UITableView
静态单元格中制作单元格或选择动态原型之间的区别。
I want to know the difference between making the cells in my UITableView
"Static Cells" or choosing "Dynamic Prototypes".
如果我想制作一个 UITableView
,它有一个+按钮来添加单元格(如设置闹钟时的Contacts App或Clock)。我应该选择哪一个?
If I want to make a UITableView
that has a "+" button to add cells (like Contacts App or Clock when setting an alarm). Which one should I choose?
推荐答案
静态单元基本上是Interface Builder中的所见即所得。您在 UITableView
中添加的内容就是您在运行应用程序时所看到的内容。
Static cells are basically a "what you see is what you get" in Interface Builder. What you put into the UITableView
is what you'll see when you run the app.
动态原型,而不是,允许您通过调用来布置可以重复使用的单元格:
Dynamic prototypes, instead, allow you to lay out cells that you can re-use by calling:
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CELL_ID_SET_IN_IB];
这样,您可以使用中的委托方法确定单元格数量的UITableViewController
。您可以拥有多个原型单元格,并根据索引路径确定要加载的单元格。
With this, you determine the number of cells using the delegate methods in the UITableViewController
. You can have multiple prototype cells and determine which to load depending on index path.
您可以将segues与两者一起使用。
You can use segues with both.
我会为您的应用推荐原型,因为从您的问题来看,您所拥有的单元格数量似乎会发生变化。
I would recommend prototypes for your app since it seems like, from your question, the number of cells you have will change.
这篇关于静态单元和动态原型之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!