我创建了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'
}
....
在我的情节提要中,我已经使用刚刚创建的类将segue设置为custom。
最佳答案
尝试这样的事情:
-(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'
}
....