【发布时间】:2016-11-20 04:50:10
【问题描述】:
我可以在多个视图控制器中使用选择器getUpdate: 吗?我将我的LevelViewController 注册为GameViewController 和WinViewController 的观察员。后两个视图控制器都有一个后退按钮(按下该按钮时,会将您弹回LevelVC),通知的想法是告诉LevelVC是否更新集合视图单元格(通过@ 987654327@ 方法)按下后退按钮时。
在viewWillAppear: 中,我不想调用两个单独的方法(一个来自GameVC,一个来自WinVC)来获取我的更新,我只需要一个可以在其中使用的流体方法。
这就是我的意图(LevelVC):
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(getUpdate:)
name:@"getUpdateForCell"
object:nil];
}
并合并
- (void)getUpdate:(NSNotification *)notification {
NSDictionary *data = [notification userInfo];
// pop
}
两次...一次在GameVC,另一次在WinVC。
这可能吗?还是我应该只发出两个单独的通知?
【问题讨论】:
标签: ios uiviewcontroller notifications nsnotificationcenter