我在下面有一些来源。为什么这会导致SIGABRT错误?
- (void)Button:(UIButton *)button {
NSString *imageName = ((UIButton *)[self.view viewWithTag:button.tag]).titleLabel.text;
}
- (void)viewDidLoad {
NSMutableArray *_array = [[NSMutableArray alloc] init];
NSInteger iCount = [_array count];
for (i = 0; iCount > i; i++) {
UIButton *btn = [[UIButton alloc] init];
btn.titleLabel.text = [[_array objectAtIndex:i] objectForKey:@"FILE"];
btn.tag = i;
[btn addTarget:self action:@selector(Button:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
[btn release];
}
当我使用0索引标记访问Button方法时,出现SIGABRT错误。 我能做什么?
你得到这个错误,因为你传递的自己的对象实际上是视图控制器,而不是按钮。 – rishi 2012-04-24 06:25:54