Я добавил NSNotificationCenter
в UIView
, когда я впервые зашел на страницу, NSNotificationCenter
работает нормально. Однако, когда я покинул эту страницу и обратно на эту страницу еще раз, он будет выдавать ошибкуiOS Исключение добавления NSNotificationCenter в UIView
'NSInvalidArgumentException', reason: '-[UITextMagnifierTimeWeightedPoint updateProfile:]: unrecognized selector sent to instance.
Вот код.
UIView1:
- (void)changeUIView {
UIView2 *view = [[UIView2 alloc] init];
// show UIView2
}
UIView2:
- (id)init {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateProfile:) name:@"updateProfile" object:nil];
return self;
}
-(void)updateProfile:(NSNotification *)notification {
// do something
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:@"updateProfile"];
}
- (void)buttonClick {
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateProfile" object:nil userInfo:nil];
}
где вы выполняете инициализацию супервизора? –
Я обновил сообщение –