iOS 页面跳转
从一个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]; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。