开发者

Navigate to root viewcontroller on button click

First off I'm new at programming. I'm creating an app with one navigation bar controller. The app is pretty basic except for a quiz section that is comprised of 12 xibs. As the users takes the quiz a new xib is pushed onto the stack. I want to create a button that takes the user back to the home screen if they do not want to complete the quiz. The back button takes them to the previous xib 开发者_如何学JAVAwhich could be 11 deep. Is it possible to dismiss the modal views and reload the rootView controller?

Here's the code from my delegate

@synthesize window;
@synthesize navigationController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after application launch
    [window addSubview:[navigationController view]];
 [window makeKeyAndVisible];
}



    -(void)dealloc {  

           [window release];  

           [navigationController release];  

           [super dealloc];  
        }

This is how I'm pushing new xibs onto the stack

-(IBAction) showTesting: (id)sender {
 Testing *varTesting = [[[Testing alloc] initWithNibName:@"Testing" bundle:nil] autorelease];
 [[self navigationController] pushViewController:varTesting animated: YES];
}

Any help would be greatly appreciated. Thanks


You can just call popToRootViewControllerAnimated: to go back to the first view controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜