EXC_BAD_ACCESS on button press for button dynamically added to UIView within UIScrollView

Posted by alan on Stack Overflow See other posts from Stack Overflow or by alan
Published on 2010-05-30T22:47:00Z Indexed on 2010/05/30 22:52 UTC
Read the original article Hit count: 278

Filed under:
|
|
|

OK. It's an iPad app. Within the DetailViewController I have added a UIScrollView through IB and within that UIScrollView I have added a UIView (also added through IB) which holds various dynamically added UITableViews, UILabels and UIButtons.
My problem is that I'm getting errors on the UIButton clicks.

I have defined this method:

- (void)translationSearch:(id)sender {  
    NSLog(@"in transearch");    
    [self doSearch];  
}  

This is how I'm adding the UIButton to the UIView:

    UIButton *translationButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    translationButton.frame = CGRectMake(6, 200, 200, 20);
    translationButton.backgroundColor = [UIColor clearColor];
    [translationButton setTitle:@"testing" forState:UIControlStateNormal];
    [translationButton addTarget:self action:@selector(translationSearch:) forControlEvents:UIControlEventTouchUpInside];       
    [verbView addSubview:translationButton];  

Now the button is added to the form without any issue but, when I press it, I am getting an EXC_BAD_ACCESS error. I'm sure it's staring me in the face but I've passed my usual time limit for getting a bug like this fixed so any help would be greatly appreciated. The only thing I can think is the fact that the UIButton is within a UIView which is within a UIScrollView which is within the view controller is somehow causing an issue.

Cheers.

© Stack Overflow or respective owner

Related posts about dynamic

Related posts about ipad