粘贴操作上的 UITextView stange 动画故障(iOS11) [英] UITextView stange animation glitch on paste action (iOS11)
问题描述
我正面临一个非常奇怪的错误.当我在 UITextView
中粘贴任何内容时,我收到了一个令人惊讶的动画故障.
为了重现它,我刚刚创建了一个黑色的 .xcodeproj
,通过故事板将 UITextView
添加到 ViewController
并运行应用程序.>
我发现的唯一类似问题是 https://twitter.com/twostraws/status/972914692195790849它说这是iOS11中UIKit
的一个错误.但是我的 iPhone 上有很多带有 UITextview
的应用程序可以在 iOS11 上正常运行.您可以在此处查看视频中的错误 – https://twitter.com/twostraws/status/972914692195790849
任何建议或帮助将不胜感激.我尝试了什么?- 以最少的更改尝试了新的清晰项目;- 禁用所有自动更正类型;- 删除了限制;- 在多款不同版本的 iPhone 上尝试过 – 11.2.5 和 11.4.2.
附上原项目.它是在 Swift 4.1
和 Xcode 9.4(9F1027a)
上制作的https://ufile.io/fzyj8
我在我的 iPhone 上检查了一些其他应用程序,比如 Todoist
并在那里发现了同样的错误.但我也找到了解决方案.我希望 Apple 会尽快修复这个错误.
所以你可以实现 UITextPasteDelegate
并禁用粘贴动作的动画.这个API只有iOS11+才有,不过貌似这个bug也只在iOS11上重现.
class ViewController: UIViewController {@IBOutlet 弱变量 textView:UITextView!覆盖 func viewDidLoad() {super.viewDidLoad()textView.pasteDelegate = self}}扩展视图控制器:UITextPasteDelegate {func textPasteConfigurationSupporting(_ textPasteConfigurationSupporting: UITextPasteConfigurationSupporting, shouldAnimatePasteOf attributesString: NSAttributedString, to textRange: UITextRange) ->布尔{返回假}}
I'm facing a very strange bug. When I paste anything inside UITextView
, I receive a surprising glitch of animation.
To reproduce it I've just created a black .xcodeproj
, added UITextView
to ViewController
via storyboard and ran the application.
The only similiar problem I've found is https://twitter.com/twostraws/status/972914692195790849
And it says that it's a bug of UIKit
in iOS11. But there lot of applications on my iPhone with UITextview
that works correctly on iOS11.
You can see the bug in the video here – https://twitter.com/twostraws/status/972914692195790849
Any suggestions or help would be appreciated. What I tried? - Tried the new clear project with minimal changes; - Disabled all the autocorrection types; - Removed constraints; - Tried on several iPhones with different version – 11.2.5 and 11.4.2.
The original project is attached. It's made on Swift 4.1
with Xcode 9.4(9F1027a)
https://ufile.io/fzyj8
I checked some other applications on my iPhone like Todoist
and found the same bug there. But also I've found the solution.
I hope Apple will urgently fix this bug.
So you may implement the UITextPasteDelegate
and disabled the animation on paste action. This API is available only iOS11+, but it seems that the bug is also reproduced only on iOS11.
class ViewController: UIViewController {
@IBOutlet weak var textView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
textView.pasteDelegate = self
}
}
extension ViewController: UITextPasteDelegate {
func textPasteConfigurationSupporting(_ textPasteConfigurationSupporting: UITextPasteConfigurationSupporting, shouldAnimatePasteOf attributedString: NSAttributedString, to textRange: UITextRange) -> Bool {
return false
}
}
这篇关于粘贴操作上的 UITextView stange 动画故障(iOS11)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!