views:

256

answers:

1

Hello,

I have a scroll view; inside I add one or more text views; to each text view I add a button:

UIScrollView
   UITexView
      UIButton
   UITextView
      UIButton
   ...

This is part of the code:


- (void)viewDidLoad {
   ...
   [self loadUI];
   ...
}

-(void) loadUI {
   UITextView *textView;
   ...
   for (...) {
      UIButton *editButton = [[UIButton alloc] initWithFrame:
CGRectMake(self.scrollView.frame.size.width - 230, 0, 50, 20)];
      ...
      [editButton addTarget:self action:@selector(editPressed:) 
forControlEvents:UIControlEventTouchUpInside];
      ...
      textView = [[CustomTextView alloc] initWithFrame:
CGRectMake(10, dynamicHeight, self.queuedView.frame.size.width - 100, 500)];
      textView.userInteractionEnabled = NO;
      ...
      [textView addSubview:editButton];
      [editButton release];
      ...
      [self.scrollView addSubview:textView];
      [textView release];
   }
}

- (IBAction) editPressed:(id)sender {
   ...
}

For some reason, the editPressed method is not called when I press the button. Any ideas why? I tried setting the interaction enabled for the text view to YES, but still nothing. I changed form (IBAction) to (void), still nothing.

Thank you, Mihai

A: 

Apparently, textView.userInteractionEnabled = YES; did the trick. I tried this before but it did not work. Maybe I had to do a clean build after the change.

Mihai Fonoage