我有一個簡單的UITableView。一切正常工作在iOS 7上,但在iOS 8上沒有。基本上我有一個自定義的UITableViewCell,其中包含文本標籤,按鈕,圖像。當我按下tableview單元格內的按鈕時,出現錯誤。下面是代碼:UITableView iOS 8 Xcode 6.0.1無法識別的選擇器發送到實例
-(IBAction)addToFavorites:(id)sender {
UIButton *editButton = (UIButton*)sender;
GetMoreTableViewCell *editCell = (GetMoreTableViewCell*)[[[editButton superview] superview] superview];
int editIndex = (int)[[_chapters indexPathForCell:editCell] row];
[self readTopScorePlist];
if([[[[_data valueForKey:key] valueForKey:[NSString stringWithFormat:@"%i",editIndex]] valueForKey:@"isDefault"] boolValue] == YES) {
[editCell.addButton setImage:[UIImage imageNamed:@"fav_0.png"] forState:UIControlStateNormal];
[self saveToPlist:NO sender:sender];
NSLog(@"NEW %@",[[[_data valueForKey:key] valueForKey:[NSString stringWithFormat:@"%i",editIndex]] valueForKey:@"isDefault"]);
}
else {
[editCell.addButton setImage:[UIImage imageNamed:@"fav_1.png"] forState:UIControlStateNormal];
[self saveToPlist:YES sender:sender];
NSLog(@"NEW %@",[[[_data valueForKey:key] valueForKey:[NSString stringWithFormat:@"%i",editIndex]] valueForKey:@"isDefault"]);
}
}
的方法被稱爲然而,在這裏,我得到異常:[editCell.addButton setImage:[UIImage imageNamed:@"fav_0.png"] forState:UIControlStateNormal];
,而且我得到了厚望是:
2014-09-22 10:08:28.223 HandyHoch[657:252982] -[UITableViewWrapperView addButton]: unrecognized selector sent to instance 0x17e9fd80
我猜測Add按鈕不能被發現,但我應該在iOS 8中做到這一點?提前致謝。
The UITableViewCell custom class:
@implementation GetMoreTableViewCell
@synthesize ttitle, cellImage, cellBackground, changeButton, deleteButton,addButton;
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if(self) {
ttitle.textColor = [UIColor whiteColor];
ttitle.numberOfLines = 30;
ttitle.lineBreakMode = NSLineBreakByCharWrapping;
ttitle.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:ttitle];
[self.contentView addSubview:addButton];
[self setAutoresizesSubviews:YES];
}
return self;
}
@end
請發佈您的'GetMoreTableViewCell'類的代碼。 – rebello95 2014-09-22 07:21:07
我編輯了我的文章 – 2014-09-22 07:43:32