views:

151

answers:

1

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.

+1  A: 

Thanks Maz. I have just done that and I have to admit that my assumption about where the error was coming from was wrong. It was a new bit of code, just not the button method call.

Grant me the "dunce" award for this one.

alan