开发者

Multiple UITableViews as sub views

I'm working on a little app to get the grips with Objective-C and the UIKit. My application shall simply display the menus for every weekday that are served at the individual canteens at my university.


I have a view containing a UIToolbar which itself contains a UISegmentedControl to switch between the days. The remaining screen space shall be used for the Table View displaying the dishes served by one canteen at a certain weekday. Now, how do I do this?

I have a Canteen that has 5 Menus (one for every day) and each of these Menus contains an arbitrary number of Dishes. The business logic is actually working totally fine by now.

How do I connect my views to my business logic. In my opinion, there are three possible ways and I have no idea which 开发者_开发知识库one I should choose:

  1. My CanteenController - which owns the UIToolbar mentioned above - does everything. It implements the protocols necessary to manage a UITableView and it owns the UITableView that displays the dishes.

  2. I have a MenuController that uses the CanteenController's UITableView - so the UITableView is shared among the 5 MenuControllers.

  3. I have 5 MenuControllers that have there very own UITableViews and every time I switch between days I replace the current UITableView of my CanteenController with the right one.

Is there such thing as a correct solution for this problem? I think, all of these solutions should work, but maybe I should prefer one of them.


Any of these solutions will work, and in most cases none of them will cause performance or memory issues. One advantage to option 3 is that you could easily fade between them upon selection with

[UIView animateWithDuration:0.5 animations:^{ /*show new top view by setting alpha from 0 to 1 and bring it to the front*/ }];


1 - would be my pick, and reload the data of the table when a new toolbar item is selected. this allows for less memory to used, which is numero uno stipulation when looking at Apple documentation...Don't use anymore memory than you have to."

2 - doesn't make sense to me

3 - i think would be better handled by a TabBarController that automatically does the view switching for you between each view controller.**

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜