简体   繁体   中英

Workflow iOS app / Custom navigation + tab bar controller

This is my very very first post ever on this amazing community. Been browsing it for quite a while now and I'm totally in love with it.

I've been learning iOS for a few weeks now and still struggling about the best way to achieve a robust and solid structure for the application I'm building. I figured out the " UITabBarController " was the best way to achieve my goal, but still, I wanted the tab-bar to go away and make my own 'extreme' custom navigation. The custom navigation would be a UIViewController with a view, and the view containing UIButtons .

So this appears in my AppDelegate.m :

// ASSIGN CUSTOM NAV & TAB BAR CONTROLLER 
[self.window setRootViewController:tabBarController];
[tabBarController.view addSubview:customNavController.view];

And I have this in my AppDelegate.h :

@property (strong, nonatomic) CustomNavigationViewController* customNavController;
@property (strong, nonatomic) UITabBarController* tabBarController;

Is this the right way to do it? So I can always go to my AppDelegate and have my customNavController available to send messages to.. And my tabBarController as well, to set the selectedIndex property for example.

So the main question remains: I have a UITabBarController (holding all the sections of the app) and a UIViewController (custom navigation) and I'd like them to be able to talk to eachother .

UPDATE: Here's a screenshot of the scheme how I see the flow in my head: https://www.dropbox.com/s/5k49pe2idn6zxcd/ios_customnavigation_scheme.png

Any tricks / tips are welcome! Curious what you guys come up with. Thanks in advance, Y.

I'm not quite sure how you intend to use these controllers in your app or why you need them to talk to one another but you can embed UINavigationControllers in each of the 'tabs' of the UITabBarController. You can also hide the Tab bar in your customer views if necessary (plenty of questions/answers on this if you search the site). These built in controllers will then handle view changes without you having to deal with the details and is of course much easier then rolling your own.

If you haven't i would review the Apple documentation on MVC as it might help you make some of your design decisions.

Best of luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM