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

标签 ios objective-c xcode segue uistoryboardsegue

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

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

在我的 Storyboard中,我已经使用刚刚创建的类将 segue 设置为自定义。

最佳答案

尝试这样的事情:

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

关于ios - 设置 UIStoryboardSegue 子类的属性 [模态 segue 上的可选动画],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22098885/

相关文章:

ios - XCode: 'pod init' ruby​​ json "incompatible library version"错误失败

ios - 如何在swift中通过通知传递多个值

objective-c - 如何使用桥接头将 Objective-C cocoapod 导入 Swift

iOS 9 : KVO no longer working

ios - 如何从学校报纸网站访问文章并在发布新文章时更新我的​​应用程序?

ios - 在 UITextView 中显示富文本文件导致断断续续/缓慢滚动

iphone - 无法从 C++ 文件访问对象属性 (Cocos2D/Box2d)

objective-c - 后台网络调用 - iOS

ios - Swift - 集成 GameCenter 以使用排行榜

ios - 'IBOutlet' 属性具有非可选类型 'UIButton'