ios - 不隐藏在键盘下方的文本字段动画,在 IOS 7 中的模拟和实际设备中表现不同

标签 ios objective-c uiscrollview ios7 uitextfield

在设备中,它在导航栏下方滚动,但在模拟器中,它会弹出到导航栏中,因此导航栏隐藏了文本字段。

///这是用于开始编辑的文本字段。

- (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/

相关文章:

iphone - 将 iphone/ipod 内存歌曲设置为铃声

iphone - 从窗口中移除时 UIScrollview contentOffset 发生变化

ios - 插入新行后如何停止 UITableView 滚动到顶部?

ios - XIB 中 View 的正确宽度?

ios - Word Wrap 不适用于 UILabel

ios - 在swift 3中将json解析为数组

objective-c - UICollectionView 可滚动年 View : performance issue

objective-c - iOS 应用中的文本阅读体验

ios - API错误信息的国际化

ios - 如何打印json数据