Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Alhazred

macrumors member
Original poster
Jul 5, 2011
35
0
Is there a way to trigger an action when a user taps inside a textview area?
I know that I could put an invisible button on it, but that makes impossible to scroll the text.
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Quite easy..
You have delegate methods on your UITextView (UITextViewDelegate).
TextviewDidBeginEditing (or something similair, i'll leave it up to you to find that out.).
THen trigger a action there..
for eg.
[self doMethod1];
or do a performSelector after Delay 4.

You're smart enough to find the rest out.
 

Alhazred

macrumors member
Original poster
Jul 5, 2011
35
0
Here what I've done, but with no luck:
int the nib file I've linked the UIView as delegate for the textview

I've declared my view conltroller in this way
@interface PickItemDetailViewController : UIViewController <UITextViewDelegate> {

then in the .m file I've put
- (void)textViewDidBeginEditing:(UITextView *)textView {
NSLog(@"textViewDidBeginEditing");
}

but nothing appears inside the console.

Do I miss anything?
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
You don't need to link the UIView as a delegate, because, it's the textView that you need as delegate..
you can set it in your code too. if you added the delegate (in your header file).

You can just do this

myTextView.delegate = self (in your viewDidLoad).

And then it should be triggered (if the correct myTextView is connected via IB), in other words -->
IBOutlet myTextView *myTextView;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.