Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 270
katleta3000 Avatar asked Jan 27 '23 15:01

katleta3000


1 Answers

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
    }
}
like image 142
katleta3000 Avatar answered Jan 30 '23 05:01

katleta3000