2010-05-30 89 views
0

OK。这是一款iPad应用程序。在DetailViewController中,我通过IB添加了UIScrollView,并在该UIScrollView中添加了一个UIView(也通过IB添加),其中包含各种动态添加的UITableViews,UILabels和UIButtons。
我的问题是,我得到的UIButton点击错误。EXC_BAD_ACCESS on按钮按下按钮以动态添加到UIView内的UIView

我已经定义了这个方法:

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

这是我如何加入UIButton的到的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]; 

现在的按钮被添加到形式,无任何问题,但是,当我按下它时,我得到一个EXC_BAD_ACCESS错误。我确信它正在凝视着我,但我已经超过了我通常的时间限制来修复这样的错误,所以任何帮助都将不胜感激。我唯一能想到的是,UIButton在UIView内,它在视图控制器内部的UIScrollView内部,导致了一个问题。

干杯。

+1

尝试将其作为调试运行以查找导致错误的行。 – Maz 2010-05-30 22:54:48

回答

1

感谢Maz。我刚刚这样做,我不得不承认,我对错误来自哪里的假设是错误的。这是一个新的代码,而不是按钮方法调用。

授予我这个“笨蛋”奖。