Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

ios - What's the difference between static cells and dynamic prototypes?

I want to know the difference between making the cells in my UITableView "Static Cells" or choosing "Dynamic Prototypes".

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?

question from:https://stackoverflow.com/questions/8641742/whats-the-difference-between-static-cells-and-dynamic-prototypes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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];

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...