Push segue in xcode with no animation
Solution 1:
I was able to do this by creating a custom segue (based on this link).
- Create a new segue class (see below).
- Open your Storyboard and select the segue.
- Set the class to
PushNoAnimationSegue
(or whatever you decided to call it).
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
Solution 2:
You can uncheck "Animates" in Interface Builder for iOS 9
Solution 3:
Ian's answer works great!
Here's a Swift version of the Segue, if anyone needs:
UPDATED FOR SWIFT 5, MAY 2020
PushNoAnimationSegue.swift
import UIKit
/// Move to the next screen without an animation
class PushNoAnimationSegue: UIStoryboardSegue {
override func perform() {
if let navigation = source.navigationController {
navigation.pushViewController(destination as UIViewController, animated: false)
}
}
Solution 4:
I have now managed to do this using the following code:
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];
Hope this helps someone else!