我有2个视图(视图A和视图B)。
在viewA中,当我触摸按钮时,我执行此代码以翻转viewB:
viewB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewB animated:YES];
现在当我回到viewA时,我使用了这段代码:
[self dismissModalViewControllerAnimated: YES]; //here is my problem
执行dismiss时,我需要为viewA设置相同的参数。 我该怎么办?
修改 我没有找到任何解决方案,我以这种方式使用了pushNavigation:
FirstViewController *viewA = [self.storyboard instantiateViewControllerWithIdentifier:@"myView"];
// Effettuo il push alla view successiva
[self.navigationController pushViewController:viewA animated:YES];
答案 0 :(得分:0)
搜索代理示例或只是使用NSNotificationCenter将消息从一个视图发送到另一个视图
ClassA的:
@protocol myDelegate
@interface ClassA : UIViewController {
}
@end
@protocol myDelegate
- (void)thingsDone:(id)someValues;
@end
ClassB的:
#import "ClassA.h"
@interface ClassB : UIViewController <myDelegate> {
}
@end
答案 1 :(得分:0)
您有两种选择:
1-您可以使用delegate pattern并将viewA注册为委托对象:
viewB.delegate = self;
[self presentModalViewController:viewB animated:YES];
在viewB中,您可以向代表发送消息:
[delegate someMethod];
2-您可以在viewB中保持指向viewA的指针:
viewB.viewA = self;
[self presentModalViewController:viewB animated:YES];
然后您可以直接向viewA发送消息:
[viewA someMethod];