简体   繁体   English

出现键盘时,UIScrollView“滞后”

[英]UIScrollView is “lagging” when keyboard appears

After searching a couple of hours, i still got an issue using UIScrollView and Keyboard. 搜索几个小时后,使用UIScrollView和Keyboard仍然出现问题。 When the keyboard is Showing up i am resizing the ScrollView with the contentInset attribute through a keyboardWillShow method. 当键盘显示出来时,我正在通过keyboardWillShow方法使用contentInset属性调整ScrollView的大小。

I'm using Autolayout with good constraints 我在使用自动布局时有很好的约束

func keyboardWillShow(notification:NSNotification)
{
   var userInfo = notification.userInfo!
   var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).CGRectValue()  
   keyboardFrame = self.view.convertRect(keyboardFrame, fromView: nil)  
   var contentInset:UIEdgeInsets = self.ScrollView.contentInset
   contentInset.bottom = keyboardFrame.size.height
   self.ScrollView.contentInset = contentInset
}

Is it an Xcode issue or am i doing something wrong? 是Xcode问题还是我做错了什么?

Thanks in advance 提前致谢

First of all you might want to check if you have "Slow Animations" turned on in your iOS Simulator. 首先,您可能需要检查iOS模拟器中是否已启用“慢动画”。

Xcode中

If not one possible reason is your macs' speed. 如果不是,可能的原因之一就是Mac的速度。 Usually every app runs faster on the actual device, then on the simulator. 通常,每个应用程序在实际设备上运行速度都更快,然后在模拟器上运行速度更快。 I would suggest you to test-build on a real device. 我建议您在真实设备上进行测试构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM