作者aecho (星空下的鲔鱼)
看板MacDev
标题Re: [问题] 换UIViewController时的Animation
时间Wed Jan 20 06:04:00 2010
※ 引述《haman (...)》之铭言:
: 不好意思
: 想请问一个关於Animation的问题
: 我在主要的ViewController A中使用
: [UIView beginAnimations: @"View Flip" context: nil];
: [UIView setAnimationDuration: 1.0f];
: [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
: [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView: self.view cache: YES];
: mySaveViewController = [[SaveViewController alloc] init];
: [self.view addSubview: mySaveViewController.view];
: [UIView commitAnimations];
: 而进到了下一个UIViesController B
这边是把mySaveViewController.view当成目前的self.view的subView,
其它的UIView的static method是为了动画效果,
但是这边显示的方式,是在self.view上面加了一个subView,
并且盖过self.view。
: 但是我想要从B回到A时 使用了
: [UIView beginAnimations: @"View Flip" context: nil];
: [UIView setAnimationDuration: 1.0f];
: [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
: [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView: self.view cache: YES];
: [self.view removeFromSuperview];
既然是要回到原本的self.view的效果,
想当然的,应该是把self.view上的subView给移掉。
不过我看过的范例是,在self这个controller里,
maintain另外两个controller的view,
随着需要,替换到self.view上的sub view。
像是要显示A 的画面的话,就是
[B.view removeFromSuperview];
[self.view addSubView:A.view];
显示B 的画面的话,就是
[A.view removeFromSupuerview];
[self.view addSubView:B.view];
: [UIView commitAnimations];
: 却没有出现翻页的动画效果
: 想请问一下该如何解决这个问题]
: 谢谢
--
格局决定了结局
个性决定了命运
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.216.233.223
1F:推 haman:所以意思是说 当我用了 01/20 06:18
2F:→ haman:[self.view addSubview: mySaveViewController.view]; 之後 01/20 06:19
3F:→ haman:我的self.view还是原来的SaveViewController.view吗??? 01/20 06:19
4F:→ haman:喔不好意思讲错... 01/20 06:20
5F:→ haman:应该说那段程式之後 我的self.view还是原来的self.veiw 01/20 06:20
6F:→ haman:而不是mySaveViewController.view 是这样子吗??? 01/20 06:21
7F:推 haman:还有想问的是 为什麽这边使用exchangeSubview时 不管index用 01/20 07:07
8F:→ haman:0, 1, 2 结果都只是同一个画面在转而已... @ @" 01/20 07:07