您的位置:首页 > 其它

从一个ViewController切换到另一个ViewController有下面几种方法:

2015-02-12 09:57 393 查看
(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];

总结:系统提供了我们视图切换的方法以及视图切换的默认动画,我们可以选择这几种方法中的去使用,也可以自定义切换的动画animation,我知道的就这些大家有别的欢迎评论我,我重新整理这篇文章
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: