Reputation: 611
I created a subclass of UIStoryboardSegue
in order to achieve a modal segue with optional animation.
(subclass of UIStoryboardSegue
):
.h
#import <UIKit/UIKit.h>
@interface ModalSegue_OptionalAnimation : UIStoryboardSegue
@property (readwrite) BOOL withAnimation;
@end
.m
#import "ModalSegue_OptionalAnimation.h"
@implementation ModalSegue_OptionalAnimation
-(void) perform{
BOOL _withAnimation_Va = self.withAnimation;
[[[self sourceViewController] navigationController] pushViewController:[self destinationViewController] animated:_withAnimation_Va];
}
@end
But I am unsure now how to call this property from the outside.
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"segue_qVC_to_cVC_checkAnswer"]) {
CheckAnswerViewController *cVC = [segue destinationViewController];
if(segue_QVC_ISEXAM) {
//Something like this:
//segue.withAnimation = NO;
//Settings the property to NO is like 'I dont animation when performing the segue'
}
....
In my storyboard I already set the segue to custom with the just created class.
Upvotes: 0
Views: 457
Reputation: 116
Try something like this:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"segue_qVC_to_cVC_checkAnswer"]) {
CheckAnswerViewController *cVC = [segue destinationViewController];
if(segue_QVC_ISEXAM) {
ModalSegue_OptionalAnimation *customSegue = (ModalSegue_OptionalAnimation *)segue;
customSegue.withAnimation = NO;
//Something like this:
//segue.withAnimation = NO;
//Settings the property to NO is like 'I dont animation when performing the segue'
}
....
Upvotes: 2