Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modal segue no transition

How to remove the transition effect from a modal segue when displaying the modal like this:

[self performSegueWithIdentifier:@"SomeIdentifier" sender:self];

I know I can go into the storyboard and toggle between 4 different animations but I don't want any! How do I remove them?

I know I could say presentModalViewController animated: NO but I do not and can not call it this way. I need to use the performSegueWithIdentifier method.

like image 940
MobileMon Avatar asked Aug 06 '12 19:08

MobileMon


People also ask

What is a modal segue?

A modal Segue is just one VC presenting another VC modally. The VCs don't have to be part of a navigation controller and the VC being presented modally is generally considered to be a "child" of the presenting (parent) VC. The modally presented VC is usually sans any navigation bars or tab bars.

How to set a segue?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.

What is a push segue?

A push Segue is adding another VC to the navigation stack. This assumes that VC that originates the push is part of the same navigation controller that the VC that is being added to the stack belongs to. Memory management is not an issue with navigation controllers and a deep stack.


Video Answer


2 Answers

In the storyboard you can select your segue and in the Attributes Inspector uncheck "Animates". That should do it.

like image 162
Pnar Sbi Wer Avatar answered Oct 04 '22 16:10

Pnar Sbi Wer


Here's the full source of a no-animation segue:

BVNoAnimationSegue.h

#import <UIKit/UIKit.h>
@interface BVNoAnimationSegue : UIStoryboardSegue
@end

BVNoAnimationSegue.m

#import "BVNoAnimationSegue.h"

@implementation BVNoAnimationSegue

- (void)perform
{
    [[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}

@end

To use this, add the files to your project (e.g. as BVNoAnimationSegue.m/.h) then in storyboard, select 'Custom' as your Segue type and type BVNoAnimationSegue in the Segue Class box. After you've done this Xcode seems to be clever enough to add 'no animation segue' as an option when you CTRL-drag between UIViewControllers in future.

like image 39
Ben Clayton Avatar answered Oct 04 '22 15:10

Ben Clayton