Full text copy by long and text copy
Recently, I made a function to copy all the content by text. I found a method on the Internet, which is easy to use, but I encountered a problem in the process of using it.
In my project, the text control is not a UILabel, but a third-party framework OHAttributedLabel found on the Internet. I will not talk about anything else. I will mainly write about the problems I encountered here. in advance, I set a long-pressed label gesture, but I finally found that the corresponding selector method was not executed. finally, it is found that one of the override methods-(UIView *) hitTest :( CGPoint) point withEvent :( UIEvent *) event causes the selector method not to be executed, the reason for not executing the task is that the hitTest returns an nil, which affects the long-pressed gesture. The final solution is to rewrite the hitTest method and return a non-empty result. the following is a simple implementation of the replication function.
Final Effect