我已經實現了一個容器視圖控制器(ios5),現在我試圖實現自定義動畫/轉換切換視圖控制器。加載視圖時導航欄跳轉
但是在實現涉及UINavigationController的任何動畫時,我遇到了一個問題,結果與預期不符。例如,如果我使用導航欄顯示控制器時從左側動畫執行翻轉操作,則導航欄的位置會保持在原始位置下方44像素處,並且在執行動畫後,導航欄將平穩移動到原來的位置,醜...
這發生在我執行的每一個動畫,所以我想它只能與導航控制器相關。
這是我使用的翻蓋過渡
[self transitionFromViewController:fromViewController
toViewController:toViewController
duration:1.0
options:UIViewAnimationOptionTransitionNone
animations:^{
[UIView beginAnimations:@"animation2" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration: 0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:NO];
[UIView commitAnimations];
}
completion:^(BOOL finished) {
[toViewController didMoveToParentViewController:self];
[fromViewController removeFromParentViewController];
}];
代碼我也試過以下
[self transitionFromViewController:fromViewController
toViewController:toViewController
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
}
completion:^(BOOL finished) {
[toViewController didMoveToParentViewController:self];
[fromViewController removeFromParentViewController];
}];
我忘了評論整個內容是向上移動的,所以如果我設置了導航欄框架,內容視圖仍然會移動。我試圖設置兩個框架(導航欄和內容視圖),但只有導航欄移動到原始位置。 – CSharpLearning
我剛剛檢查了導航欄的框架及其在viewDidLoad和viewWillAppear(x = 0,y = 0)中的正確位置。即使導航欄從y =狀態欄高度移動到y = 0 ...奇怪... – CSharpLearning
在導航欄中添加y = 20將其設置正確 –