Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
YOL O!
57 PointsRibbit app tabbar reset view
How to a make sure that every time I press the tab bar I start with first view and for example not edit friends view instead of friends? Now it opens last active view
Peace and Love
2 Answers
Stone Preston
42,016 PointsI think you are going to have to use a UITabBarController Delegate method such astabBarController:didSelectViewController: to handle that. you would need to implement that delegate method
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
//get the current view controller (the one you want to reset back to the root view)
UIViewController *viewController = tabBarController.selectedViewController;
//pop to root view controller assuming your view controller has a navigationController
[viewController.navigationController popToRootViewControllerAnimated:NO];
}
YOL O!
57 PointsAny other ideas anyone?
YOL O!
57 PointsYOL O!
57 PointsThank you Stone Preston
I tried like this and did not work. I added in the bottom of the m file. Should I change something more?
´´´
´´´