从一个Controller跳转到另一个Controller时,一般有以下几种:
1、利用UINavigationController,调用pushViewController,进行跳转;这种采用压栈和出栈的方式,进行Controller的管理。调用popViewControllerAnimated方法可以返回。
1 PickImageViewController *ickImageViewController = [[PickImageViewController alloc] init]; 2 [self.navigationController pushViewController: ickImageViewController animated:true]; 3 [ickImageViewController release];
[self.navigationController pushViewController:subTableViewController animated:YES]; //通过 NSNavigationBar 进行跳转 [self.navigationController popViewControllerAnimated:YES]; //在子视图返回到上级视图
2、利用UIViewController自身的presentModalViewController,进行跳转;调用dismissModalViewControllerAnimated方法可以返回。
1 PickImageViewController *ickImageViewController = [[PickImageViewController alloc] init]; 2 [self presentModalViewController:ickImageViewController animated:YES]; 3 //返回 4 [self dismissModalViewControllerAnimated:YES];
AddInfo *control = [[AddInfo alloc] init]; [self presentModalViewController:control animated:YES]; [control release]; //通过事件进行跳转
[self dismissModalViewControllerAnimated:YES]; //描述:通过事件进行返回。
-(void)change:(id)sender{ second *secondview = [[second alloc] initWithNibName:@"second" bundle:nil]; [self presentViewController:secondview animated:YES completion:^{}]; }
-(IBAction)NextPage:(id)sender { Page_Second *control = [[[Page_Second alloc] initWithNibName:@"Page_Second" bundle:nil] autorelease]; //定义要跳转到页面 [self.view.window setRootViewController:control]; }