设置UIStoryboardSegue的子类属性[模态segue上的可选动画]

时间:2014-02-28 15:13:29

标签: ios objective-c xcode segue uistoryboardsegue

我创建了UIStoryboardSegue的子类,以实现带有可选动画的模态segue。

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

但我现在不确定如何从外面调用这个属性。

-(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'
        }
    ....

在我的故事板中,我已经将segue设置为刚刚创建的类。

1 个答案:

答案 0 :(得分:2)

尝试这样的事情:

-(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'
    }
....