答案 0 :(得分:0)
您必须将该视图作为主ViewController视图的直接子视图,并将其放置在视图的底部。这可以按照你想要的任何方式完成。然后把它移到"胶水"键盘显示或隐藏时,它会显示在视图的底部,您必须在UIKeyboardWillShowNotification
中收听UIKeyboardWillHideNotification
和NSNotificationCenter
。当这些事件触发时,您可以模仿动画持续时间和缓动方法,并在willshow和willhide函数中向上或向下移动您的底部视图。像这样:
- (void)keyboardWillShow:(NSNotification *)aNotification
{
NSDictionary* userInfo = [aNotification userInfo];
// Get animation info from userInfo
NSTimeInterval animationDuration;
UIViewAnimationCurve animationCurve;
CGRect keyboardEndFrame;
[[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&animationCurve];
[[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&animationDuration];
[[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardEndFrame];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:animationDuration];
[UIView setAnimationCurve:animationCurve];
//Do whatever you would like to here, likely move your bottom view
[UIView commitAnimations];
}