开发者

Disabling Magnifying Glass in UITextView in an iPhone App

I want to display text and I want to be able开发者_如何学运维 to know where in this text a user touches. Because the text could be long, I wanted to use a UITextView so that wrapping and everything would be taken care of. I want my own event handling for when a touch begins or moves. My problem is that the magnifying glass and select/select all menu are interrupting my touchesMoved events.

How can i disable the magnifying glass, but still have user interaction enabled so that I can detect the touches?


You have to create a subclass and override these two functions to disable select/select all/copy/ and magnifying

select/select all/copy/:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender

Reference: https://stackoverflow.com/a/1429320/1526023

magnifying:

- UILongPressGestureRecognizer
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer

Reference: https://stackoverflow.com/a/10641203/1526023


I'd suggest to check the gestureRecognizers property.

You will find a lot of them in the array and might want to either remove them all or to find the ones that triggers the event you want to intercept and remove/replace it.

I used it to remove copy/paste and magnifying glass functionalities from an UITextField


You might try the tips offered here: How disable Copy, Cut, Select, Select All in UITextView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜