我自定义了后退按钮的动作。如果按下返回,我想向父视图发送一个 BOOL,但布尔值始终为空。
我的父母.h
[...skip...]
BOOL myBool;
[...skip....]
我的父母.m
#import "theChild.h"
....
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"myBool is %d", (int)myBool);
}
-(IBAction)callTheChild:(id)sender {
theChild *theChildVC = [[theChild alloc] initWithNibName:@"theChild" bundle:nil];
// set something
[self.navigationController pushViewController:theChildVC animated:YES];
[theChildVC release];
}
在我的孩子.m
#import "theParent.h"
....
....
-(void)backAction:(id)sender {
theParent *theParentVC = [[addSite alloc] init];
// set parent BOOL
theParentVC.myBool = YES;
[addVC release];
// dismiss child view
[self.navigationController popViewControllerAnimated:YES];
}
当父级出现时,myBool 为空。
如果我改变
[self.navigationController popViewControllerAnimated:YES];
到
[self.navigationController pushViewController:theParentVC animated:YES];
一切正常,但由于几个原因不是我想要的。
任何帮助表示赞赏。
谢谢,马克斯