7

I have a UITextView wrapped inside a UIView which can be resized (increasing frame and font size), and the magnifying glass works fine with smaller textview sizes

Magnifying glass working normal

But if I increase the textview size a lot, the magnifying glass starts going out of its frame

enter image description here

Can I just remove the magnifying glass without affecting cursor selection, or decrease the scale value inside the glass so the content fits its frame?

Efesus
  • 197
  • 2
  • 17
  • http://stackoverflow.com/questions/10640781/disable-magnifying-glass-in-uitextview – iPatel Aug 24 '13 at 11:49
  • I do not want to remove UILongPressGestureRecognizer, I want to be able to move the cursor inside the textView, just without the magnifying glass, or decrease magnifying glass scale size so the text fits inside magnifying glass' frame – Efesus Aug 24 '13 at 12:01

2 Answers2

2

Ok, managed to disable magnifying glass without removing the ability to move curser.

To do that, I removed the UILongPressGestureRecognizer to get rid of magnifying glass. Then used my UIPanGestureRecognizer to track the touch location of the user

CGPoint currentPos = [panRecognizer locationInView:self];

and then set the cursor location

UITextPosition *cursorPosition=[self closestPositionToPoint:CGPointMake(currentPos.x, currentPos.y)];
[self setSelectedTextRange:[self textRangeFromPosition:cursorPosition toPosition:cursorPosition]]; 
Efesus
  • 197
  • 2
  • 17
0

To disable the magnifying glass just set the userInteractionEnabled property to NO. After that you have to manually call becomeFirstResponder when the UITextField is tapped. You can use a TapGestureRecognizer to do that.

Abdullah Shafique
  • 6,878
  • 8
  • 35
  • 70
  • I do not wish to disable user interaction altogether, I just want to disable the magnifying glass. Also I have a hitTest that overrides userInteractionEnabled property – Efesus Aug 24 '13 at 11:51