佳为好友

原:关于Custom Container View Controller -2012.08.23

创建:2012.08.22
修改:2012.08.23
参考:
WON'T SOMEBODY PLEASE THINK OF THE CHILDREN?!?
Containing ViewControllers

iOS5加入了几个函数用于自定义ContainerVC。
原来的ContainerVC没有办法接受到旋转,内存不足等消息。
*加入子VC的方法:
[self addChildViewController:self.childVC];
[self.view addSubview:self.childVC.view];
[self.childVC didMoveToParentViewController:self];
注意:
1)要手动调用didMoveToParentViewController: 这是SDK说的。
2)要手动调用addSubview:
*去掉子VC的方法:
[self.childVC willMoveToParentViewController:nil]; 
[self.childVC.view removeFromSuperview];
[self.childVC removeFromParentViewController];
注意:
1)要手动调用willMoveToParentViewController:nil 这是SDK说的。
2)要手动调用removeFromSuperview。
3)有人说,不要在子VC中调用removeFromParentViewController,否则会出现异常行为,我没测试过。
*切换子VC
transitionFromViewController:toViewController:duration:options:animations:completion:
子VC可以并存于父VC中,可以只存在一个,这个和普通的子VC没有什么差别。
唯一要注意的是:transitionFromViewController:toViewController:duration:options:animations:completion函数会自动删掉上一个子VC的view,并加入新的子VC的view而已。--这是我猜测
另外,这个函数我没有用过,看看其他人的建议吧:
  1. You can only transition to views that have been explicitly added / contained using AddChildViewController
  2. UIVIewAnimationOptions have some new additions, check them out!
  3. The "animations" and "completionHandler" parameters are both delegates. This means all your pre-animation targets and post-animation events all accessible within one expression, cool stuff!
  4. As with most things, make sure to call base.Transition(..) [super transisionFromViewController:..] if you override this, or you'll get weird behavior.
+++++

posted on 2012-12-29 10:49 佳为好友 阅读(410) 评论(0)  编辑 收藏 引用 所属分类: UI


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

留言簿(1)

随笔分类

搜索

最新评论

评论排行榜