【发布时间】:2014-09-08 02:51:03
【问题描述】:
我正在尝试在 iPad 上实现一些自定义转换,但遇到了一些问题。由于x,y坐标并不总是从左上角的transitionContext的containerView开始旋转设备时我写了以下方法
- (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时,出现以下问题:导航栏变小,当过渡结束时变为正常状态,如图所示
发生转换时导航栏出现问题
过渡完成后
我不确定这些是来自苹果的错误还是我做错了什么,如果是,我该如何解决这些问题?
【问题讨论】:
-
@Spynet 我尝试在表格视图中更改它,但不幸的是没有任何更改
-
看起来还是一样或有一些额外的行为......
-
@Spynet 看起来完全一样。当我使用自动布局时它看起来也一样
-
你能多解释一下你有2张桌子还是1张桌子和
标签: ios uiviewanimationtransition