我的代码:
-(void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboard:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
-(void)viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(void)handleKeyboard:(NSNotification*)notification {
NSLog(@"triggered");
}
请参阅:
消失的处理程序正常触发一次,但出现时则触发3次。这是iOS错误吗?
答案 0 :(得分:0)
可能对您的问题没有帮助,但您需要致电[super viewWill…
进行覆盖。
-(void)viewWillAppear:(BOOL)animated
-(void)viewWillDisappear:(BOOL)animated
来自文档。
如果覆盖此方法,则必须在某个时刻调用super 你的实施。