【问题标题】:Modal segue no transition模态转场无过渡
【发布时间】:2012-08-06 19:39:07
【问题描述】:

当像这样显示模态时如何从模态转场中移除过渡效果:

[self performSegueWithIdentifier:@"SomeIdentifier" sender:self];

我知道我可以进入情节提要并在 4 个不同的动画之间切换,但我不想要任何一个!如何删除它们?

我知道我可以说presentModalViewController animated: NO,但我不会也不能这样称呼它。我需要使用performSegueWithIdentifier 方法。

【问题讨论】:

    标签: objective-c ios storyboard modalviewcontroller


    【解决方案1】:

    在情节提要中,您可以选择转场并在属性检查器中取消选中“动画”。应该这样做。

    【讨论】:

    • 最佳答案!这应该是官方的答案!
    • 这仅适用于模态样式,推送没有“动画”选项
    【解决方案2】:

    这是无动画转场的完整来源:

    BVNoAnimationSegue.h

    #import <UIKit/UIKit.h>
    @interface BVNoAnimationSegue : UIStoryboardSegue
    @end
    

    BVNoAnimationSegue.m

    #import "BVNoAnimationSegue.h"
    
    @implementation BVNoAnimationSegue
    
    - (void)perform
    {
        [[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
    }
    
    @end
    

    要使用它,请将文件添加到您的项目(例如,作为 BVNoAnimationSegue.m/.h),然后在情节提要中,选择“自定义”作为您的 Segue 类型并在 Segue Class 框中键入 BVNoAnimationSegue .完成此操作后,Xcode 似乎足够聪明,可以在将来在 UIViewController 之间按住 CTRL 拖动时添加“无动画转场”作为选项。

    【讨论】:

      【解决方案3】:

      如果您需要转场但不想要动画,则需要制作自定义转场(没有动画)。

      您应该在视图控制器编程指南中查看 Apples "creating custom segues" example,他们会在没有动画的情况下进行自定义模态转场(就像您想要的那样)。

      【讨论】:

        【解决方案4】:

        另一种方法

        YourViewController *aYourViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"aYourViewControllerIdentifier"];
        [self.navigationController pushViewController:aYourViewController animated:NO];
        

        并将@"aYourViewControllerIdentifier" 添加到情节提要中的视图控制器。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-10-06
          相关资源
          最近更新 更多