我在下面有一些來源。爲什麼這會導致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