我对键盘消失的通知有点问题,我添加了观察者:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidDisappear:)
name:UIKeyboardWillHideNotification
object:nil];
添加方法:
- (void) keyboardDidDisappear:(NSNotification *)notification {
NSLog(@"disappear");
}
在我的应用程序中,我有一些按钮,单击它会显示两个使用此方法的 uitextfield:
- (void) showFieldStoryView:(id)sender {
if (storyContentView.hidden == NO) {
UIButton *button = (UIButton *)sender;
buttonTag = [button tag];
int indexArray = buttonTag - 1;
NSMutableDictionary *dict = [arrayPunteggi objectAtIndex:indexArray];
[fieldUno removeFromSuperview];
[fieldDue removeFromSuperview];
[fieldUno setHidden:YES];
[fieldDue setHidden:YES];
[storyContentView addSubview:fieldUno];
[storyContentView addSubview:fieldDue];
[fieldUnoAccusi removeFromSuperview];
[fieldDueAccusi removeFromSuperview];
[fieldUnoAccusi setHidden:YES];
[fieldDueAccusi setHidden:YES];
[labelPunti removeFromSuperview];
[labelAccusi removeFromSuperview];
[labelPunti setHidden:YES];
[labelAccusi setHidden:YES];
[storyContentView addSubview:labelPunti];
[storyContentView addSubview:labelAccusi];
if (fieldUno.isFirstResponder) {
point = CGPointMake(0,button.frame.origin.y);
}
else {
[fieldUno becomeFirstResponder];
}
}
}
问题是每次单击此按钮时,我都会在控制台上看到日志消失,奇怪的是键盘总是显示屏幕,问题出在哪里?