推SEGUE在Xcode没有动画(Push segue in xcode with no anima

2019-09-01 02:28发布

我使用的普通故事板,并在Xcode推塞格斯,但我想有一个刚刚出现的下来看,不会滑动下一个视图塞格斯(如当你使用一个标签栏和下一个视图只是出现)。

是否有一个很好的简单的方法,有正常的推塞格斯只是“似乎”,而不是“幻灯片”,而无需添加自定义塞格斯?

一切工作完全没问题,我只是想删除的观点之间的幻灯片动画。

Answer 1:

我能够通过创建自定义赛格瑞(基于这样做此链接 )。

  1. 创建一个新的类赛格瑞(见下文)。
  2. 打开你的故事板,并选择SEGUE。
  3. 设置类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


Answer 2:

您可以在Interface Builder中取消勾选“动画”适用于iOS 9



Answer 3:

伊恩的回答的伟大工程!

下面是Segue公司的雨燕版本,如果有人需要:

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)
        }
    }

}


Answer 4:

现在,我已经成功地做到这一点使用下面的代码:

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];

希望这可以帮助别人!



Answer 5:

下面是适用于模态地呈现视图控制器没有动画版雨燕:

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)
    }

}


Answer 6:

回答使用Swift3 -

对于“推” SEGUE:

class PushNoAnimationSegue: UIStoryboardSegue
{
    override func perform()
    {
       source.navigationController?.pushViewController(destination, animated: false)
    }
}

是“模式”如下:

class ModalNoAnimationSegue: UIStoryboardSegue
{
    override func perform() {
        self.source.present(destination, animated: false, completion: nil)
    }
}


Answer 7:

对于使用Xamarin iOS的任何自定义SEGUE类需要这个样子:

[Register ("PushNoAnimationSegue")]
public class PushNoAnimationSegue : UIStoryboardSegue
{
    public PushNoAnimationSegue(IntPtr handle) : base (handle)
    {

    }

    public override void Perform ()
    {
        SourceViewController.NavigationController.PushViewController (DestinationViewController, false);
    }
}

不要忘了,你仍然需要在你的故事板设置自定义SEGUE和类设置为PushNoAnimationSegue类。



Answer 8:

对我来说,这样做最简单的方法是:

UIView.performWithoutAnimation { 

        self.performSegueWithIdentifier("yourSegueIdentifier", sender: nil)

    }

从iOS的7.0可用



Answer 9:

我使用Visual Studio的W / Xamarin和设计师不提供dtochetto的答案“进行动画”复选标记。

需要注意的是Xcode的设计师将应用以下属性在.storyboard文件SEGUE元素:动画=“NO”

我手动编辑.storyboard文件和动画加入=“NO”给SEGUE元件(多个),并且它为我工作。

例:

 <segue id="1234" destination="ZB0-vP-ctU" kind="modal" modalTransitionStyle="crossDissolve" animates="NO" identifier="screen1ToScreen2"/>


Answer 10:

PUSH无动画:雨燕这里是我工作。

import ObjectiveC

private var AssociatedObjectHandle: UInt8 = 0
    extension UIViewController {

        var isAnimationRequired:Bool {
            get {
        return (objc_getAssociatedObject(self, &AssociatedObjectHandle) as? Bool) ?? true
            }
            set {
                objc_setAssociatedObject(self, &AssociatedObjectHandle, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
            }
        }
    }

    -------------------- SilencePushSegue --------------------

class SilencePushSegue: UIStoryboardSegue {

    override func perform() {
        if self.source.isAnimationRequired == false {
            self.source.navigationController?.pushViewController(self.destination, animated: false)
        }else{
            self.source.navigationController?.pushViewController(self.destination, animated: true)
        }
    }
}

使用方法 :设置从故事板SEGUE类如上图。 从您的视图控制器为false从那里,你想打电话performSegue,当你想推赛格瑞没有动画,并呼吁self.performSegue后重新设置为true设置isAnimationRequired。 祝您好运....

DispatchQueue.main.async {
                self.isAnimationRequired = false
                self.performSegue(withIdentifier: "showAllOrders", sender: self);
                self.isAnimationRequired = true
            }



Answer 11:

刚刚成立animated UINavigationController.pushViewController斯威夫特

self.navigationController!.pushViewController(viewController, animated: false)


文章来源: Push segue in xcode with no animation