IOS屏幕切换方法 - 原
ios中界面切换可以分为使用导航控制器uinavigationcontroller或者其他的方法进入或者返回界面。
1, 适用uinavigationcontroller
这个就是将界面压栈处理,好处是可以自动生成back按钮和返回效果。并且如果考虑屏幕旋转的统一性就是说如果所有的页面旋转的方式是一样的话那么就适用这种方法很方便。减少代码量。
self.rootView = [[ScrollPageController alloc]initWithNibName:@"ScrollPageController" bundle:nil];
self.navController = [[UINavigationController alloc]initWithRootViewController:self.rootView];
self.window.rootViewController = self.navController;
push页面出来:
DoLoginViewController * dologinViewCtrl = [[DoLoginViewController alloc] initWithNibName:@"DoLoginViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dologinViewCtrl animated:NO];
[dologinViewCtrl release];
隐藏导航栏:
- (void)viewWillAppear:(BOOL)animated
{
/////////////////////////////////
[self.navigationController setNavigationBarHidden:YES];
}
2, 不适用push方法,自定义界面手动push和pop窗口
5.0及以上版本:
进入下一个页面:
DoLoginViewController * dologinViewCtrl = [[DoLoginViewController alloc] initWithNibName:@"DoLoginViewController" bundle:[NSBundle mainBundle]];
dologinViewCtrl.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:dologinViewCtrl animated:YES completion:nil];
返回上一个页面:
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"back");
}];
self.rootView = [[ScrollPageController alloc]initWithNibName:@"ScrollPageController" bundle:nil];
self.navController = [[UINavigationController alloc]initWithRootViewController:self.rootView];
self.window.rootViewController = self.navController;
push页面出来:
DoLoginViewController * dologinViewCtrl = [[DoLoginViewController alloc] initWithNibName:@"DoLoginViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dologinViewCtrl animated:NO];
[dologinViewCtrl release];
隐藏导航栏:
- (void)viewWillAppear:(BOOL)animated
{
/////////////////////////////////
[self.navigationController setNavigationBarHidden:YES];
}
2, 不适用push方法,自定义界面手动push和pop窗口
5.0及以上版本:
进入下一个页面:
DoLoginViewController * dologinViewCtrl = [[DoLoginViewController alloc] initWithNibName:@"DoLoginViewController" bundle:[NSBundle mainBundle]];
dologinViewCtrl.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:dologinViewCtrl animated:YES completion:nil];
返回上一个页面:
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"back");
}];