ParentViewController is nil no matter what I do
My controller hierachy:
- TabBaseController (UITabBarController)
- SubclassedController
In my tabbasecontroller I have a navigation bar button, which flips the subclassedcontroller with the presentModalViewController method, to a second UITabBarController.
So my question is: why does not
self.parentViewController
work in the second UITabBarController? It is nil.
I am trying this in my viewDidLoad method in the second UITabBarController:
if (self.parentViewController == nil) {
NSLog(@"Parent is nil");
}
UPDATED
This is the method in the UITabBarController with the navigationItemButton that presents it
-(IBAction)openModalTabController:(id)sender {
if (self.nvc == nil) {
ModalTabController *vc = [[ModalTabController alloc] init];
self.nvc = vc;
[vc release];
}
[self presentModalViewController:self.nvc animated:YES];
}
This is the controller(UITabBarController) that I present modally:
Header:
@interface NewBuildingViewController : UITabBarController {
}
@end
Main:
@implementation NewBuildingViewController
- (id)init {
[super initWithNibName:nil bundle:nil];
ViewController1 *vc1 = [[ViewController1 alloc] init];
ViewController2 *vc2 = [[ViewController2 alloc] init];
ViewController3 *vc3 = [[ViewController3 alloc] init];
NSArray *controllers = [[NSArray alloc] initWithObjects:vc1, vc2, vc3, nil];
[vc1 release];
[vc2 release];
[vc3 release];
self.viewControllers = controllers;
[controllers release];
self.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
return self;
}
- (id)in开发者_运维知识库itWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
return [self init];
}
@end
I also want to add that this message is displayed in the console(warning) when flipping:
Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations. Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate
It would be helpful if you were to show how you are presenting that second UITabBarController. Are you perhaps ignoring the following warning found in the UITabBarController class reference?
When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.
精彩评论