在Xcode推动赛格没有animation
我正在使用正常的故事板,并在xcode中推入segse,但是我希望只出现下一个视图的segues,而不是滑动下一个视图(如在使用选项卡栏和下一个视图时出现)。
有没有一个简单的方法来正常的推出只是“出现”,而不是“幻灯片”,而不需要添加自定义赛格?
一切工作都很好,我只是想删除视图之间的幻灯片animation。
我能够通过创build一个自定义的segue(基于这个链接 )来做到这一点 。
- 创build一个新的segue类(见下文)。
- 打开你的故事板,并select继续。
- 将类设置为PushNoAnimationSegue(或者你决定调用它的任何东西)。
  
 
斯威夫特4
 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 
PushNoAnimationSegue.m
 #import "PushNoAnimationSegue.h" @implementation PushNoAnimationSegue - (void)perform { [self.sourceViewController.navigationController pushViewController:self.destinationViewController animated:NO]; } @end 
您可以在iOS 9的界面生成器中取消选中“animation”
  
 
伊恩的答案很好!
如果有人需要,这里有一个Segue的Swift版本:
PushNoAnimationSegue.swift
 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) } } } 
我现在设法使用下面的代码来做到这一点:
 CreditsViewController *creditspage = [self.storyboard instantiateViewControllerWithIdentifier:@"Credits"]; [UIView beginAnimations:@"flipping view" context:nil]; [UIView setAnimationDuration:0.75]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:YES]; [self.navigationController pushViewController:creditspage animated:NO]; [UIView commitAnimations]; 
希望这可以帮助别人!
这里的Swift版本适合模态地呈现一个没有animation的ViewController:
 import UIKit /// Present the next screen without an animation. class ModalNoAnimationSegue: UIStoryboardSegue { override func perform() { self.sourceViewController.presentViewController( self.destinationViewController as! UIViewController, animated: false, completion: nil) } } 
对于任何使用Xamarin iOS的人来说,自定义的segue类需要如下所示:
 [Register ("PushNoAnimationSegue")] public class PushNoAnimationSegue : UIStoryboardSegue { public PushNoAnimationSegue(IntPtr handle) : base (handle) { } public override void Perform () { SourceViewController.NavigationController.PushViewController (DestinationViewController, false); } } 
不要忘记,你仍然需要在故事板中设置自定义的继续,并将类设置为PushNoAnimationSegue类。
回答使用Swift3 –
为“推”继续:
 class PushNoAnimationSegue: UIStoryboardSegue { override func perform() { source.navigationController?.pushViewController(destination, animated: false) } } 
for“modal”segue:
 class ModalNoAnimationSegue: UIStoryboardSegue { override func perform() { self.source.present(destination, animated: false, completion: nil) } } 
对我来说,最简单的方法是:
 UIView.performWithoutAnimation { self.performSegueWithIdentifier("yourSegueIdentifier", sender: nil) } 
从iOS 7.0可用
我正在使用Visual Studio w / Xamarin,并且devise人员不提供dtochetto答案中的“Animates”复选标记。
请注意,XCodedevise器会将以下属性应用于.storyboard文件中的segue元素:animates =“NO”
我手动编辑.storyboard文件,并添加animation=“NO”到segue元素(S),它为我工作。
例:
  <segue id="1234" destination="ZB0-vP-ctU" kind="modal" modalTransitionStyle="crossDissolve" animates="NO" identifier="screen1ToScreen2"/> 
 只需在Swift中的UINavigationController.pushViewController上设置animated false 
 self.navigationController!.pushViewController(viewController, animated: false) 
- 如何animationUILabel的背景颜色?
- 正确的方法来优化iOS / Mobile Safari的CSS 3animation?
- 在iPhone上摇动视觉效果(不摇动设备)
- 如何使用核心animation在iPhone上的2个图像之间交叉淡入淡出
- 如何识别animationDidStop代表中的CAAnimation?
- 我可以更改Android的startActivity()过渡animation?
- 还原iOS7以前的UINavigationController pushViewControlleranimation
- 我在哪里可以find一些示例WPFanimation?
- Android,沿着path移动位图?