添加观察员通知您,当键盘出现或消失,按以下条件适应您的看法:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
然后实现这些方法。
- (void)keyboardWillShow:(NSNotification*)notification
{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
// the above is the keyboard size, implement prober view resizing as you wish, but i recommend a scrollview and you scroll it.
}
然后
- (void)keyboardWillHide:(NSNotification *)notification
{
//get everything back to original size or set the scrollview content size back to block scrolling.
}
末不要忘记被用于键盘观察员删除自己在视图中消失
- (void)viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
调整您在键盘出现时查看的大小。 – sanjeet
只是因为词可能是骗人的,下面是我试图实现的效果的图片:https://imgur.com/ckXEina – overkill
你可以显示较低的白色UIView的限制吗? – juanjo