Question

I am attempting to load a temporary, slide-in, view from another view controller. My application's view controllers are structured:

Application > Tab Bar Controller > TabBarItem > View Controller

In this view controller, I have a button that successfully fires a method to load the temporary view:

- (IBAction)displayTimePickerViewForDayButton:(id)sender {

    NSLog(@"displayTimePickerViewForDayButton method entered.");

    // create the selector view controller and become the delegate
    WOTimePickerViewController *tpvc = [[WOTimePickerViewController alloc] initWithNibName:@"WOTimePickerView" bundle:nil];
    tpvc.delegate = self;
    tpvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    [self presentModalViewController:tpvc animated:YES];
    [tpvc release];
}

I have verified that my WOTimePickerViewController is successfully returning from the init method but the view never enters it's viewDidLoad method.

So, if I look at the view in IB, it appears to be connected to the vc's "view" property. When I run the view in the simulator (from IB) it renders correctly.

When I run the app from XCODE, I can navigate to the view, click my button, and a blank white screen appears (note this is not the white background of the view that should load).

Was it helpful?

Solution

You should do it like this..

WOTimePickerViewController *tpvc = [[WOTimePickerViewController alloc] initWithNibName:@"WOTimePickerView" bundle:nil];
    tpvc.delegate = self;
UINavigationController *navCntrlr = [[UINavigationController alloc] initWithRootViewController:tpvc];
    navCntrlr.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    [self.navigationController presentModalViewController:tpvc animated:YES];
    [tpvc release];

But the important thing you are missing is you are not doing it right.

you should do it like:

[self.navigationController presentModalViewController:tpvc animated:YES];

and when you want to dismiss the modalView controller you should do it like:

[self.navigationController dismissModalViewControllerAnimated:YES];

OTHER TIPS

I think the modalTransitionStyle of the view controller applies to modal views shown from that view controller. So if you want to use the UIModalTransitionStyleCoverVertical transition to display your modal controller, you should set the modalTransitionStyle property on the parent view controller (self), not the new one.

I don't have any experience using the modalTransitionStyle, but maybe setting that property before the view is loaded is causing some issues? I'd try commenting it out...

It sounds like everything is configured correctly in IB. As long as your File's Owner is the view controller, and it's view outlet is bound to the view you should be good.

Hope that helps,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top