我刚刚决定在虚拟键盘打开时向上移动整个框架。它看起来并不坏。
- (void)keyboardWasShown:(NSNotification*)aNotification {
// NSLog(@"It's appeared.");
keyboardup = true;
[self.view setFrame:CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y-300,self.view.frame.size.width,self.view.frame.size.height)];
}
- (void)keyboardWillBeHidden:(NSNotification*)aNotification {
// NSLog(@"It's gone");
keyboardup = false;
[self.view setFrame:CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y+300,self.view.frame.size.width,self.view.frame.size.height)];
}
- (void)keyboardCallingNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}