简体   繁体   中英

UITextView stange animation glitch on paste action (iOS11)

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
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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