I am creating a tabBarApplication in which there is one tab on which camera opens.After clicking on the use tab of the imagepicker I push a new class.
Now my problem is when I again press camera tab that class gets open AND I want that camera should gets opened basically my rootviewcontroller of that tab.
Any suggestions will be appreciated.
Thanks in advance!
You can implement this delegate method, when the selected view controller is camera controller, you can popToRootViewController.
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
Related
I have made an app in which i have 2 tabs.and there are navigation controller in them,
The issue is that once i click on the tab bar and there is navigation bar and the view changes as i drill down.But when i go to the second tab and then come back to the 1st tab then it opens the view which was there previously when i changed the tab.So it retain the view whereas i want that that tab should start up with the same first initial view.
From where we can do this by info.plist or what..>?
Thanks in advance ...
Adopt UITabBarControllerDelegate protocol and implement tabBarController:shouldSelectViewController: method.
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)controller {
[(UINavigationController *)controller popToRootViewControllerAnimated:NO];
return YES;
}
This assumes that all tabs have navigation controllers.
That's not how tab view controllers work. You can implement this method in your app delegate (after making it the delegate for the UITabeBarController)....
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
Then call a reset method (or similar) on your view controller to pop back to the root view controller.
This is not how you normally work with UITabBarControllers however....
You can implement
- tabBarController:didSelectViewController:
in the delegate of the UITabBarController and then call
– popToRootViewControllerAnimated:
on the UINavigationController
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.
I have a tab bar control and need a method in the view controller of each tab to get called once a tab bar item is selected.
Does anybody know which method gets called?
Thanks
You can implement a UITabBarControllerdelegate and then you have:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
where you retrieve the viewController on which you can call whatever method.
You also get the tabBarController that contains all the viewControllers on which you could iterate to call the method
viewWillAppear:(BOOL)animated
viewDidAppear:(BOOL)animated
I have several tabs in my tab bar controller and only one (the first one) for which I would need an automated reload each time I select its tab (and also when the app come back to the foreground).
I did not find how to do this, do I need to recreate the tab bar controller manually each time ? Do I need to add a new set of view controllers to the tab bar controller ?
Thanks for your help
Would it make sense to have a updateView functio that you can call in viewWillAppear on that particular view that ensures everything is up-to-date each time the view is set to appear?
If your UIViewController is a UITabBarControllerDelegate it will get this callback, which is what you want, I believe:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
Simply return YES after calling your updateView method.
Let's say I have a Tab Bar Controller with a tab A. A has a navigation controller, which lets me push new views onto the stack. Right now, if I tap A on the Tab Bar, all of the elements in A's stack will pop.
Is there a nice way to disable this? I have a sequence of views that are displayed with the navigation controller that takes user input would not like all of that to be lost with a slip of the finger.
Thanks in advance, and please let me know if my question is unclear.
Try setting up a delegate for your UITabBarController, and implement:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
If the same view controller is being selected, return NO. Then the navigation stack should not change.
Note it will only be called for the same tab you are already on from iOS 3.0 on, but at this point I would only target iOS 3.0+.