作者denru01 (阿儒)
看板MacDev
标题Re: [问题] 换UIViewController时的Animation
时间Thu Jan 21 22:16:58 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
: 但是我想要从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];
: [UIView commitAnimations];
: 却没有出现翻页的动画效果
: 想请问一下该如何解决这个问题]
: 谢谢
我想是加注解的那个部分出问题。
我猜Animation的运作方式是,先指定要负责animation的view(标记的method),
这时负责的view会将该时显示的结果记录下来。
接着采取改变view的方法,再呼叫[UIView commitAnimations],来进行新旧画面
的animation。
因此,
第一个add subview方法不会出问题,
因为你只是把B的View放到A的View上面,
使用者可以看到viewA,也就是可以看到animation效果。
但第二个会出错,因为你指定由viewB来进行animation,但却将他从superview中移除,
即使他有进行animation,使用者也看不到,
使用者只看的到你将viewB移除这件事。
解决方法是,
将第二个方法的负责view改为viewA,应该就可以正常运作。
不一定要使用到delegate这麽复杂。
只要找到他的superview,指定给他即可。
--
▂▃▄▃▂
◢
˙ ◣
˙ ▅
▉▃ /◤
喵喵~~~~
▊▏
◣╲ˍ ╱▎
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.218.68
1F:推 haman:感谢XD 01/21 23:01