UITextView startInteractionWithLinkAtPoint crash iOS 11 only

后端 未结 2 1936
遥遥无期
遥遥无期 2020-12-10 16:20

So I experience crash in UItextview while user interacts with URL link there. All crash reports have iOS version 11 only. This looks like well-known bug in iOS 9, but there

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 17:14

    A crash is caused by a UIDragInteraction/UITextDragAssistant on iOS 11.0 and 11.1. It is fixed on iOS 11.2. Subclassing your UITextView and disabling drag and drop gestures will prevent the crash for any iOS version:

    class NoDragDropTextView: UITextView {
    
        override func addGestureRecognizer(_ gestureRecognizer: UIGestureRecognizer) {
    
            // required to prevent drag and drop gestures
            // also prevents a crash on iOS 11.0-11.1
            gestureRecognizer.isEnabled = false
    
            super.addGestureRecognizer(gestureRecognizer)
        }
    }
    

提交回复
热议问题