3

I'm trying to implemet a scrollable Text view (not editable) that display some help information etc. and when the user is done with it all he has to do is tap it and it will disapear/hidden and the user will be back in the main screen.

The UITextview not reacting to tap event (or i'm not sure how to make it react to the tap event). Any idea how to implement this ?

I also tried to put it inside a transparent button so i can capture the tap but then i cannot scroll the text view as it seem to be behinde the button.

i'm new to iphone , any help... gr8

Thanks

Stk Stocki
  • 139
  • 3
  • 8

1 Answers1

12

How about adding a tap gesture recognizer to the text view?

UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(textViewTapped:)];
[yourTextView addGestureRecognizer:gestureRecognizer];
Shmidt
  • 16,436
  • 18
  • 88
  • 136
yuji
  • 16,695
  • 4
  • 63
  • 64
  • 3
    make sure to include `[yourTextView setUserInteractionEnabled:YES]` – EagerMike Apr 02 '12 at 20:21
  • Hi guys, I added the code to the viewDidLoad() method and It worked. I hope it's the correct place to add that.. That being said I noticed that in my xib/nib screen i don't have any gesture recognizers objects to select from the lib. I saw a small a vid that the developer dragged it onto an image but I don't see them..? I'm using Xcode 4.1 developer library. Any insight why i can't see those objects? THanks!! – Stk Stocki Apr 02 '12 at 20:29
  • Yup, that's exactly the right place to put that, since the view hierarchy is guaranteed to have been set up at that point. – yuji Apr 02 '12 at 20:31
  • 1
    Just to clarify for rookies like me, action:SEL(textViewTapped:) should be action:@selector(textViewTapped:) – Joshua Dance Jun 04 '13 at 18:44