import UIKit
/*
Move to the next screen without an animation.
*/
class PushNoAnimationSegue: UIStoryboardSegue {
override func perform() {
self.source.navigationController?.pushViewController(self.destination, animated: false)
}
}
目标C.
PushNoAnimationSegue.h
#import <UIKit/UIKit.h>
/*
Move to the next screen without an animation.
*/
@interface PushNoAnimationSegue : UIStoryboardSegue
@end
import UIKit
/// Move to the next screen without an animation.
class PushNoAnimationSegue: UIStoryboardSegue {
override func perform() {
let source = sourceViewController as UIViewController
if let navigation = source.navigationController {
navigation.pushViewController(destinationViewController as UIViewController, animated: false)
}
}
}
11 回答
我能够通过创建自定义segue(基于this link)来完成此操作 .
创建一个新的segue类(见下文) .
打开故事板并选择segue .
将类设置为
PushNoAnimationSegue
(或您决定调用它的任何内容) .斯威夫特4
目标C.
PushNoAnimationSegue.h
PushNoAnimationSegue.m
您可以在Interface Builder for iOS 9中取消选中“Animates”
伊恩的回答非常好!
如果有人需要,这是一个Swift版本的Segue:
PushNoAnimationSegue.swift
我现在设法使用以下代码执行此操作:
希望这有助于其他人!
这是适用于 modally present 没有动画的ViewController的Swift版本:
使用 Swift3 回答 -
为“推”segue:
对于“模态”segue:
对于使用Xamarin iOS的任何人,您的自定义segue类需要如下所示:
不要忘记您仍然需要在故事板中设置自定义segue并将类设置为PushNoAnimationSegue类 .
对我来说,最简单的方法是:
可从iOS 7.0获得
我正在使用Visual Studio w / Xamarin,设计师没有在dtochetto的答案中提供“Animates”复选标记 .
请注意,XCode设计器将以下属性应用于.storyboard文件中的segue元素:animates =“NO”
我手动编辑了.storyboard文件,并在segue元素中添加了animates =“NO”,这对我有用 .
例:
PUSH WITHOUT ANIMATION : Swift 这对我有用 .
Usage :从故事板中设置segue类,如图所示 . 当你想要在没有动画的情况下推送segue并在调用self.performSegue之后将其设置回true时,将viewController中的isAnimationRequired设置为false,从而调用performSegue . 祝你好运....
只需在Swift中的
UINavigationController.pushViewController
上设置animated
false 即可