我遵循了苹果指南Managing keyboard
除非您已经在新文本字段中的文本字段和制表符中书写,否则它就像魅力一样。
这是示例中用于处理滚动的函数。但它永远不会被调用,因为它已经出现了?
- (void)keyboardWasShown:(NSNotification*)aNotification;
任何人都知道解决这个问题的好方法吗?
答案 0 :(得分:1)
接口:
CGSize keyboardSize;
BOOL keyboardIsVisible;
实现,keyboardWasShown:
keyboardSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
keyboardIsVisible = YES;
// Move ScrollView
keyboardWillBeHidden:
keyboardIsVisible = NO;
textFieldDidBeginEditing:
if (keyboardIsVisible) {
// Move ScrollView
}
答案 1 :(得分:1)
in .h
CGSize keyboardSize;
和
- (void)keyboardWasShown:(NSNotification*)aNotification;
in .m
- (void)keyboardWasShown:(NSNotification*)aNotification {
NSDictionary* info = [aNotification userInfo];
if (info) {
/* Can get keyboard Size */
keyboardSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey]
}
/* Animation code */
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
activeField = textField;
[self keyboardWasShown:[NSNotification notificationWithName:UIKeyboardDidShowNotification object:nil]];
}
感谢vakio。