我試圖在iPad上實現一些自定義轉換,但我遇到了一些問題。由於X,Y座標不總是在transitionContext
的containerView
左上角開始時設備旋轉我寫了下面的方法iOS 7自定義轉換問題
- (CGRect)rectForPresentedStateStart:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIView *containerView = [transitionContext containerView];
switch (fromViewController.interfaceOrientation)
{
case UIInterfaceOrientationLandscapeRight:
return CGRectMake(0, containerView.bounds.size.height,
containerView.bounds.size.width, containerView.bounds.size.height * 2/3);
case UIInterfaceOrientationLandscapeLeft:
return CGRectMake(0, - containerView.bounds.size.height * 2/3,
containerView.bounds.size.height, containerView.bounds.size.height * 2/3);
case UIInterfaceOrientationPortraitUpsideDown:
return CGRectMake(- containerView.bounds.size.width * 2/3, 0,
containerView.bounds.size.width * 2/3, containerView.bounds.size.height);
case UIInterfaceOrientationPortrait:
return CGRectMake(containerView.bounds.size.width, 0,
containerView.bounds.size.width * 2/3, containerView.bounds.size.height);
default:
return CGRectZero;
}
}
- (CGRect)rectForPresentedStateEnd:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *containerView = [transitionContext containerView];
switch (toViewController.interfaceOrientation)
{
case UIInterfaceOrientationLandscapeRight:
return CGRectOffset([self rectForPresentedStateStart:transitionContext], 0, - containerView.bounds.size.height * 2/3);
case UIInterfaceOrientationLandscapeLeft:
return CGRectOffset([self rectForPresentedStateStart:transitionContext], 0, containerView.bounds.size.height * 2/3);
case UIInterfaceOrientationPortraitUpsideDown:
return CGRectOffset([self rectForPresentedStateStart:transitionContext], containerView.bounds.size.width * 2/3, 0);
case UIInterfaceOrientationPortrait:
return CGRectOffset([self rectForPresentedStateStart:transitionContext], - containerView.bounds.size.width * 2/3, 0);
default:
return CGRectZero;
}
}
在肖像模式和顛倒一切似乎很好地工作。問題在於景觀。
當器件取向是
UIInterfaceOrientationLandscapeLeft
的視圖中消失用於第二過渡開始之前。當設備方向是
UIInterfaceOrientationLandscapeRight
我得到了以下問題:導航欄是很小,而且在過渡結束喜歡在照片
問題與導航變爲標準當發生轉變時
過渡完成後
或我不知道如果這些蟲子從蘋果,如果我做錯了什麼,如果是我該如何解決這些問題?
我希望這會幫助你http://stackoverflow.com/questions/17794037/interface-builder-what-are-the-uiviews-layout-ios-6-7-deltas-for – Spynet
@Spynet我試着改變它在我的表格視圖,但不幸的是沒有任何變化 – alecnash
它仍然看起來相同或一些額外的行爲...。 – Spynet