[英]UITabBarController View Transition error
好的,我已經研究這個問題一段時間了,這遠遠超出了我的專業知識,因此我再次尋求幫助。
我正在嘗試為 tabbarbutton 單擊到另一個視圖的過渡設置動畫。 我已經在兩個 viewController (ViewWillAppear) 方法中聲明了下面的代碼
- (void)viewWillAppear:(BOOL)animated
{
//TODO: Fix transition animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.view cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView commitAnimations];
[super viewWillAppear:animated];
}
右邊是 FirstViewController,左邊是 SecondViewController。
現在問題發生在用戶第一次加載應用程序時,一旦所有內容加載完畢並且用戶單擊標簽欄按鈕到 go 到第二個視圖,它不會翻轉.. 但是當你 go 返回到 FirstView 它動畫然后,如果您將 go 再次設置為第二個,它將在這一次進行動畫處理.. 有人知道為什么會發生這種情況嗎? 如果您提供幫助,將不勝感激!
更新:: 我正在嘗試將 animation 添加到 viewDidLoad 中,但是已經有一個 animation 用於我正在立即加載的打開序列。
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//-- Start Opening Animation ------->
CGRect vaultTopFrame = vaultTop.frame;
vaultTopFrame.origin.y = -vaultTopFrame.size.height;
CGRect vaultBottomFrame = vaultBottom.frame;
vaultBottomFrame.origin.y = self.view.bounds.size.height;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.5];
[UIView setAnimationDelay:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
vaultTop.frame = vaultTopFrame;
vaultBottom.frame = vaultBottomFrame;
[self.view bringSubviewToFront:vaultTop]; //this should place this subview above any others on the same page
[self.view bringSubviewToFront:vaultBottom]; //this should place this subview above any others on the same page
[UIView commitAnimations];
我想這可能會讓我搞砸了,你怎么看?
當應用程序加載時,您沒有 animation。 當視圖加載時,在viewDidLoad
中為 animation 設置 animation ,當用戶在病房后(每次單擊選項卡時)進行轉換時, viewDidAppear
將為您提供動畫。
這可能是也可能不是問題,但您應該致電
[super viewWillAppear:animated];
在方法的開頭,在您的 animation 代碼之前。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.