Re: [問題] 換UIViewController時的Animation
※ 引述《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
推
01/21 23:01, , 1F
01/21 23:01, 1F
討論串 (同標題文章)
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章