在设备中,它在导航栏下方滚动,但在模拟器中,它会弹出到导航栏中,因此导航栏隐藏了文本字段。
///这是用于开始编辑的文本字段。
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
//textField.keyboardAppearance = UIKeyboardAppearanceAlert;
CGPoint scrollPoint;
CGRect inputFieldBounds = [textField bounds];
inputFieldBounds = [textField convertRect:inputFieldBounds toView:scrollView];
scrollPoint = inputFieldBounds.origin;
scrollPoint.x = 0;
scrollPoint.y -= 30; // you can customize this value
[scrollView setContentOffset:scrollPoint animated:YES];
}
////为了让滚动到后面,我在文本字段中写这个应该返回
-(BOOL) textFieldShouldReturn:(UITextField *)textField
{
CGPoint scrollPoint;
scrollPoint.x = 0;
scrollPoint.y = 0;// you can customize this value
[scrollView setContentOffset:scrollPoint animated:YES];
}
//// end
最佳答案
您可以尝试在viewWillAppear
中添加以下代码:
self.navigationController.navigationBar.translucent = NO;
关于ios - 不隐藏在键盘下方的文本字段动画,在 IOS 7 中的模拟和实际设备中表现不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20260390/