简体   繁体   中英

New UIView not loading

I have a TabController View setup and I am attempting to load a new view in the current tab. This view would be loaded depending on a selection from a UIAlertView.

As such I have this code attempting to do so:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

    // Yes Button
    if (buttonIndex == 0) {

        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:0]);

        user = [[UserInfo alloc] initWithNibName:@"UserInfo"  bundle:nil];
        [self.navigationController pushViewController:user animated:YES];

        [user release];
    }
    // Don't show again Button
    if (buttonIndex == 1) { 
        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:1]);
    }

    // No Button
    if (buttonIndex == 2) {
        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:2]);
    }
}

The Yes block prints out to the console, however the new view does not load. User is an instance of UserInfo, which in turn is a subclass of UIViewController. The Nib UserInfo is created and is part of the project.

What am I missing?

These two lines are unnecessary:

[user.view setHidden:NO];
[self.navigationController setView:user.view];

But this one is:

[user release];

How are you setting up your tab bar controller? Have you placed this view inside of a UINavigationController then added that navigation controller to the TabBarController?

Please review the View Controller Programming Guide for iOS (specifically the Combined ViewController Interfaces section) and verify you are nesting these views correctly.

Is user a global variable? I usually see something like
UserInfo *user = [[UserInfo alloc] initWithNibName:@"UserInfo" bundle:nil];

as the pattern. Since the navigation controller is really going to be the main owner of the view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM