键盘消失时我有一点问题,我添加了观察者:
[[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];
}
}
}
问题是,每次我点击这个按钮,我都会在控制台上看到日志消失,奇怪的是,键盘总是显示哦屏幕,问题出在哪里?