A–>跳转到B
A使用[self presentViewController:B animated:YES completion:NULL];跳转到B
B使用dismissViewControllerAnimated返回;
B代码:
[self dismissViewControllerAnimated:YES completion:^{
//关闭传值
[[NSNotificationCenter defaultCenter] postNotificationName:@“yiJiBackTo” object:self userInfo:[NSDictionary dictionaryWithObject:@“zhen” forKey:@“yiJiBackToVal”]];
}];
A代码:
在viewDidLoad方法中:NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(handleNotiChange:) name:@“yiJiBackTo” object:nil];
-(void)handleNotiChange:(NSNotification *)sender{
NSString *val = [[sender userInfo] valueForKey:@“yiJiBackToVal”];
if([val isEqualToString:@“zhen”]){
[self.navigationController popViewControllerAnimated:TRUE];
}
}