【发布时间】:2011-07-07 15:09:47
【问题描述】:
任务: 我有一个导航控制器,它推送一个模态视图,称为登录。这个登录视图有一个按钮可以推动另一个模态视图,称为注册。如果用户注册了注册模式并且登录模式应该关闭。我在登录视图中创建了一个 nsnotification,它等待来自注册提交操作的帖子。
问题 登录会收到通知,但不会关闭登录视图。我知道该方法运行,因为 NSLog 触发。
登录 viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismiss) name@"SignedUp" object nil];
登录关闭
NSLog(@"Dismiss"); // this fires
[self dismissModalViewControllerAnimated: YES];
注册方式(子控制器)
[self dismissModalViewControllerAnimated: YES];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SignedUp" object:[self parentViewController]];
在注册方法中调用dismiss后我也试过这个
[self.parentViewController dismissModalViewControllerAnimated:YES];
编辑我不会推动这些控制器。我正在使用presentModalViewController
【问题讨论】:
-
你有解决办法吗?
标签: iphone modalviewcontroller nsnotifications nsnotificationcenter