开发者

iphone tab app architecture question

I have two tabs on my app that handle different flows.

For each tab I want to have a controller that determines (based on info in the app) which view to display.

So you click on tab 1, the app goes through some logic and displays either View B or View C. From there I use a navigation controller to go to other views within that tab.

To handle the initial logic of figuring out which view (B or C) to display I have a view controller (View A) linked to the tab that handles all the logic. My issue is that if I click on tab 1 while I'm already "on" the tab it displays the view for View A, which is a blank page.

Does anyone have an idea of how to architect this or make it so the view 开发者_运维知识库for View A is never displayed?


UITabBarControllerDelegate

in your implementation of:

tabBarController:shouldSelectViewController:

you should try to detect if you are already on the first tab or not. if so just return NO and it won't pop to the root controller (in this case A)


The idea behind the MVC model is that such logic is not execute by ViewControllers but by the Model.

You could create a class or method who's purpose is to make the decision between view B or C, call the appropriate method on a button click and display the view depending on the result.

My point is: the way you describe it view A should not exist.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜