【发布时间】:2016-03-15 09:59:29
【问题描述】:
AppDelegate
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(@"applicationWillEnterForeground");
[[NSNotificationCenter defaultCenter]postNotificationName:@"applicationWillEnterForeground" object:nil];
}
V1
-(IBAction)uw:(UIStoryboardSegue*)segue{
NSLog(@"Back on V1");
}
V2
-(void)awakeFromNib {
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(goBackToV1) name:@"applicationWillEnterForeground" object:nil];
}
-(void)goBackToV1 {
NSLog(@"goBackToV1");
[self performSegueWithIdentifier:@"uwid" sender:nil];
}
V3
从V2 模态显示并且没有代码。
运行应用程序后,我点击主页按钮并再次打开应用程序,此触发通知并由V2 收到。
V2 应该做什么:
- 解雇
V3。如果V3没有ViewController子类,则将其关闭,否则不会。 -
V2本身必须从UINavigationController中弹出,但如果V3没有被解除但给出日志goBackToV1,则不会弹出。
如果在V3 我这样做NSLog(@"%@", [self presentingViewController]); 我得到<UINavigationController: 0x13582d800>
我的问题:
- 为什么
V3在没有分配 ViewController 子类时会被解雇。 - 为什么
V3在分配 ViewController 子类时不会被解雇。 - 为什么
V2上的performSegueWithIdentifier没有将其弹出到V1尽管代码已执行但其简单却被忽略了。
【问题讨论】:
标签: ios objective-c uistoryboard uistoryboardsegue nsnotificationcenter