2016-05-17 55 views
1

所以我想從我的加載屏幕viewcontroller轉換到我的應用程序的主視圖控制器。我這樣做使用UIViewControllerAnimatedTransitioning,因爲它比我以前的transitionFromView:更好。Tabbar和導航欄不能用於UIViewControllerAnimatedTransitioning

但它仍然不完美。我的視圖頂部有一個酒吧,您可以在頂部看到(A bit like this)和我視圖底部的標籤欄。

現在動畫的看法是這樣的:

enter image description here

正如你可以看到的TabBar和導航欄太高,這是立即固定在下一幀。這會導致應用閃爍。我不想要這個。我究竟做錯了什麼?如果這不是我做錯的事情,我該如何解決它? (我已經嘗試將它添加到正確尺寸的窗口,但它不起作用)

這是我的轉換代碼(它是Xamarin,但您應該能夠理解它的要點):

// Grab the from and to view controllers from the context 
var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey); 
var toViewController = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey); 

toViewController.WillMoveToParentViewController(fromViewController); 
fromViewController.View.InsertSubview(toViewController.View, 0); 
toViewController.View.LayoutIfNeeded(); 
toViewController.View.RemoveFromSuperview(); 

fromViewController.View.UserInteractionEnabled = false; 

transitionContext.ContainerView.AddSubview(fromViewController.View); 
transitionContext.ContainerView.AddSubview(toViewController.View); 

toViewController.View.Alpha = 0; 

UIView.Animate(TransitionDuration(transitionContext),() => { 
    toViewController.View.Alpha = 1; 
},() => { 
    transitionContext.CompleteTransition(true); 
    fromViewController.Dispose(); 
}); 

回答

0

我發現這個問題,我是這樣做的:

UIView.Animate(TransitionDuration(transitionContext),() => { 
    toViewController.View.Alpha = 1; 
},() => { 
    transitionContext.CompleteTransition(true); 
    fromViewController.Dispose(); 
}); 

當我應該這樣做:

PresentViewController(_controller, true, null); 

該動畫不使用transitioningDelegate,所以我實際上並沒有使用它...