Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push segue in xcode with no animation

I am using normal storyboarding and push segues in xcode, but I want to have segues that just appear the next view, not slide the next view (as in when you use a tab bar and the next view just appears).

Is there a nice simple way to have normal push segues just "appear" and not "slide", without needing to add custom segues?

Everything is working completely fine, I just want to remove that slide animation between the views.

like image 797
R2D2 Avatar asked Apr 25 '13 07:04

R2D2


1 Answers

I was able to do this by creating a custom segue (based on this link).

  1. Create a new segue class (see below).
  2. Open your Storyboard and select the segue.
  3. Set the class to PushNoAnimationSegue (or whatever you decided to call it).

Specify segue class in Xcode

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

Objective 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 
like image 171
Ian Avatar answered Sep 19 '22 21:09

Ian