&引用;“始终全屏显示视图控制器”;iOS 7自定义转换不正确?
苹果的文档(:)说“在iPhone和iPodtouch上,显示的视图总是全屏的。”但在iOS7中,有一个自定义的视图控制器转换API。已经有很多演示显示“presentedViewController”可以是我们想要的任何大小。在这种情况下,苹果的文档不是真的吗?我相信苹果仍然是正确的,尽管可能有误导性。默认情况下,它将全屏显示,但如果您提供自定义转换代理,则可以对帧执行任何操作,等等 苹果所说的全屏(我认为在这种情况下)是指它的边缘延伸到设备的最大高度和宽度。以前,它会受到导航栏或其他可能添加的工具栏的限制,但在iOS 7中,默认情况下,它们不再尊重这些工具栏 但是,通过自定义过渡,现在可以通过在过渡期间更改其帧的大小,使较小的视图控制器覆盖另一个视图控制器。有关示例,请参见Teehan&Lax发布的很棒的转换API: 下面是一个&引用;“始终全屏显示视图控制器”;iOS 7自定义转换不正确?,ios,ios7,presentviewcontroller,Ios,Ios7,Presentviewcontroller,苹果的文档(:)说“在iPhone和iPodtouch上,显示的视图总是全屏的。”但在iOS7中,有一个自定义的视图控制器转换API。已经有很多演示显示“presentedViewController”可以是我们想要的任何大小。在这种情况下,苹果的文档不是真的吗?我相信苹果仍然是正确的,尽管可能有误导性。默认情况下,它将全屏显示,但如果您提供自定义转换代理,则可以对帧执行任何操作,等等 苹果所说的全屏(我认为在这种情况下)是指它的边缘延伸到设备的最大高度和宽度。以前,它会受到导航栏或其他可能添加
-animateTransition
方法,用于将“到视图”控制器上的帧设置为一个明显不是全屏的值。注意设置endFrame
变量的行:
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
// Grab the from and to view controllers from the context
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
// Set our ending frame. We'll modify this later if we have to
CGRect endFrame = CGRectMake(80, 280, 160, 100); // <- frame is only 160 x 100
if (self.presenting) {
fromViewController.view.userInteractionEnabled = NO;
[transitionContext.containerView addSubview:fromViewController.view];
[transitionContext.containerView addSubview:toViewController.view];
CGRect startFrame = endFrame;
startFrame.origin.x += 320;
toViewController.view.frame = startFrame;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
fromViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
toViewController.view.frame = endFrame;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
else {
toViewController.view.userInteractionEnabled = YES;
[transitionContext.containerView addSubview:toViewController.view];
[transitionContext.containerView addSubview:fromViewController.view];
endFrame.origin.x += 320;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
fromViewController.view.frame = endFrame;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
}
-(void)animateTransfion:(id)transitionContext{
//从上下文中获取“从”和“到”视图控制器
UIViewController*fromViewController=[transitionContext ViewControllerWorky:UITransitionContextFromViewControllerKey];
UIViewController*toViewController=[transitionContext ViewControllerWorky:UITransitionContextToViewControllerKey];
//设置结束帧。如果有必要,我们将稍后修改此帧
CGRect endFrame=CGRectMake(80280160100);//我相信苹果仍然是正确的,尽管可能有误导性。默认情况下,它将全屏显示,但如果您提供自定义转换代理,您可以对该帧执行任何操作,等等
苹果所说的全屏(我认为在这种情况下)是指它的边缘延伸到设备的最大高度和宽度。以前它会受到导航栏或其他可能添加的工具栏的限制,但在iOS 7中,默认情况下,它们不再尊重它们
但是,通过自定义转换,您现在可以通过在转换期间更改视图控制器的帧大小,使较小的视图控制器覆盖另一个视图控制器。有关示例,请参阅Teehan&Lax的Aweasome transition API文章:
以下是-animateTransition
方法,用于将“to view”控制器上的帧设置为明显不是全屏的值。请注意设置endFrame
变量的行:
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
// Grab the from and to view controllers from the context
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
// Set our ending frame. We'll modify this later if we have to
CGRect endFrame = CGRectMake(80, 280, 160, 100); // <- frame is only 160 x 100
if (self.presenting) {
fromViewController.view.userInteractionEnabled = NO;
[transitionContext.containerView addSubview:fromViewController.view];
[transitionContext.containerView addSubview:toViewController.view];
CGRect startFrame = endFrame;
startFrame.origin.x += 320;
toViewController.view.frame = startFrame;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
fromViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
toViewController.view.frame = endFrame;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
else {
toViewController.view.userInteractionEnabled = YES;
[transitionContext.containerView addSubview:toViewController.view];
[transitionContext.containerView addSubview:fromViewController.view];
endFrame.origin.x += 320;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
fromViewController.view.frame = endFrame;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
}
-(void)animateTransfion:(id)transitionContext{
//从上下文中获取“从”和“到”视图控制器
UIViewController*fromViewController=[transitionContext ViewControllerWorky:UITransitionContextFromViewControllerKey];
UIViewController*toViewController=[transitionContext ViewControllerWorky:UITransitionContextToViewControllerKey];
//设置结束帧。如果有必要,我们将稍后修改此帧
CGRect endFrame=CGRectMake(80280160100);//苹果的文档很好。我想你只是忘记了,当你自定义转换时,你可以对框架/边界/边缘等做任何你想做的事情。默认情况下,横向iPhone 6+会将全屏演示改编成模式表单,所以从技术上讲,文档是错误的。iPhone 6+甚至会自动切换b当你在纵向和横向之间来回旋转时,在全屏和模式表单之间。@Aaron这些文档有些误导。是的,你说显示的视图是“全屏”在技术上是正确的,但这对大多数API文档的消费者没有帮助。苹果文档需要更新,以清楚地表明显示的视图可以具有完全自定义的外观,包括不显示全屏的外观。这不仅仅是风格上的一个小问题:这是一个基本的可用性问题,使API突然变得更具吸引力可以理解。苹果的文档很好。我想你只是忘记了,当你自定义转换时,你可以对框架/边界/边缘等做任何你想做的事情。默认情况下,横向iPhone 6+会将全屏演示改编成模式表单,所以从技术上讲,文档是错误的。iPhone 6+甚至会自动当您在纵向和横向之间来回旋转时,请在全屏和模式表单表之间切换。@这些文档有些误导。是的,您说显示的视图是“全屏”在技术上是正确的,但这对大多数API文档的消费者没有帮助。苹果文档需要更新,以清楚地表明显示的视图可以具有完全自定义的外观,包括不显示全屏的外观。这不仅仅是风格上的一个小问题:这是一个基本的可用性问题,使API突然变得更具吸引力这是可以理解的。