Using Tab Bar Controllers iphone iOS5
-
27-10-2019 - |
문제
Im using the new storyboarding features with ios. I have a tab bar which also has a class name called mytabbarcontroller. However I do not have a seperate class for this as in a .h/.m file for this since all its implementation is in different views which is sorted. Now i have a view controller which appears before the tab bar with an activity indicator. Once it stops it has to move to the tab bar controller. However i cant initialise it with mytabbarcontroller since i dont have .h files to import. Currently it goes to a tab bar controller with nothing on it - basically it creates a new tab bar controller. My code is as follow. I also tried initwithnibname and gave the nib name - i.e mytabbarcontroller. However this throws an error.
UITabBarController *controller = (UITabBarController *)[[UITabBarController alloc] init ];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
해결책
because you are declaring a new UITabBarController, try this instead, import and intialize the first view of the tab bar, for example
FirstSceneController.h
import "FirstTabViewController.h"
...
FirstTabViewController *firstTab = [self.storyboard instantiateViewControllerWithIdentifier:@"mytabbarcontroller"]; [firstTab setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; [self presentModalViewController:firstTab animated:YES];
.... and also be sure to add a navigation controller and connect it to your first scene.