简体   繁体   中英

in tabbar application with navigation controller how to start from first view in hierarchy of tabbar

I have tabbar based application, I want to start each time tab is pressed to start with first view they are associated with. Problem is it starts with first view when its a start of application but while using application i may navigate deep in to one tab and now what to do if i want to start it again with main view associated with that tab which is pressed?

You can use the tabbar delegates to override this behaviour. The UITabBarControllerDelegate is documented here:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html

You would want to look at: tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController

Everytime this delegate method is triggered you can trigger the corresponding navigation controller's popToRootViewController:animated method. Normally you'd have your app delegate be the tabbar controller delegate also, but that's up to your implementation.

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