戻るボタンの動作をカスタマイズしました。戻るが押された場合に BOOL を親ビューに送信したいのですが、bool 値は常に null です。
私の親.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 は null です。
私が変われば
[self.navigationController popViewControllerAnimated:YES];
に
[self.navigationController pushViewController:theParentVC animated:YES];
すべて正常に動作しますが、いくつかの理由で私が望むものではありません。
どんな助けでも大歓迎です。
ありがとう、マックス