开发者

Switching views in UINavigation controller

Hi i am new in iphone programing...My requirement is to go to from menu page in my app to 2nd view on click of button which is a table view then from there to other views...lets say an screen showing image, from this screen i want to come back to main menu..

so is it possible to do it using UINavigationController...as far i know...Navigation control allows switching using stack....so you can come back to previous screen only

Please help me!!!

or should i do it without using navigation controller...doing all stuff 开发者_StackOverflow中文版keeping a view controller as a switch manager and then from it managing all the screens..????????


I do not really understand what you want but here a few idea's.

If you just want to add a screen (no stack), use addSubview:

If you want a overlay witch you can dismiss, use presentModalViewController:animated:

Want to use a stack and a button to go directly to the root, use

[navigationController popToRootViewControllerAnimated:NO];
[navigationController pushViewController:controller animated:YES];


yes you want to use UINavigationController to manage the views/viewcontrollers.

to push a new viewcontroller use:

[navigationController pushViewController:controller animated:YES];

to pop back to the first viewcontroller use:

[navigationController popToRootViewControllerAnimated:NO];

to pop back to a specific viewcontroller use:

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];


If u want to use navigation controller then u declare a variable of navigation controller in app-delegate file as like in app deleagte.h

UINavigationController *navigationController; @property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

and in appdelegate.m file

@synthesize navigationController; - (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; }

and when u call next views then use this code on action of button or cell of table view

[self.navigationController pushViewController:self.secondView animated:YES];

above line for push view.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜