从一个ViewController切换到另一个ViewController有下面几种方法:
(1)addsubview方法切换视图
self.view addSubview:(加载的新页面);
相应的 [self.view removeFromSuperview];移除添加的view
(2)self.view insertSubview:(加载的新页面) atIndex:n;
对n的解释:页面都是层次叠加的,n表示加载到那一层上面
(3)presentModalViewController方法
photoNacController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
photoNacController.modalPresentationStyle = UIModalPresentationFullScreen;
self presentModalViewController:(加载的新页面) animated:
modalTransitionStyle用于设置页面切换的动画
modalPresentationStyle用于设置视图显示的方式
两种方法试试就知道用途了!
(4) pushViewController 导航
[self.navigationController pushViewController:(加载的新页面) animated:YES];
对应的
[self.navigationController popViewControllerAnimated:YES];
(1)addsubview方法切换视图
self.view addSubview:(加载的新页面);
相应的 [self.view removeFromSuperview];移除添加的view
(2)self.view insertSubview:(加载的新页面) atIndex:n;
对n的解释:页面都是层次叠加的,n表示加载到那一层上面
(3)presentModalViewController方法
photoNacController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
photoNacController.modalPresentationStyle = UIModalPresentationFullScreen;
self presentModalViewController:(加载的新页面) animated:
modalTransitionStyle用于设置页面切换的动画
modalPresentationStyle用于设置视图显示的方式
两种方法试试就知道用途了!
(4) pushViewController 导航
[self.navigationController pushViewController:(加载的新页面) animated:YES];
对应的
[self.navigationController popViewControllerAnimated:YES];
本文介绍了iOS中四种常见的视图切换方法:addSubview插入新视图、insertSubview定位插入新视图、presentModalViewController模态视图控制器及pushViewController进行导航。每种方法都附带了代码示例和具体说明。

被折叠的 条评论
为什么被折叠?



