好的。这是一个 iPad 应用程序。在 DetailViewController 中,我通过 IB 添加了一个 UIScrollView,在该 UIScrollView 中,我添加了一个 UIView(也通过 IB 添加),其中包含各种动态添加的 UITableView、UILabels 和 UIButton。
我的问题是我在 UIButton 点击时遇到错误。
我已经定义了这个方法:
- (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 中,而 UIView 位于视图控制器中的 UIScrollView 中,这在某种程度上导致了问题。
干杯。