我自定义了后退按钮的动作。我想发送到父视图一个布尔如果后面被按下,但布尔值始终为空。按下后退按钮时传递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];
}
在我theChild .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];
所有工作正常,但不是我想有几个原因。
任何帮助表示赞赏。
感谢, 最大
刚刚意识到我错过了'@property(nonatomic,retain)theParentVC * parent;'从Child.h中的行。另外不要忘记''父母释放];'在theChild的dealloc方法:)' – deanWombourne 2011-02-28 13:52:29
感谢您指出我在正确的方向。有效。 – masgar 2011-02-28 15:03:33