objective c - UITableView iOS 8 Xcode 6.0.1 Unrecognised Selector Send To Instance -
i have simple uitableview. works fine on ios 7 on ios 8 not. have custom uitableviewcell contains text labels, buttons, images. when press button inside tableview cell got error. here code:
-(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"]); } }
the method called getting exception here:[editcell.addbutton setimage:[uiimage imagenamed:@"fav_0.png"] forstate:uicontrolstatenormal];
and expection getting is:
2014-09-22 10:08:28.223 handyhoch[657:252982] -[uitableviewwrapperview addbutton]: unrecognized selector sent instance 0x17e9fd80
i guessing addbutton cannot finded, should in ios 8? in advance.
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
it seems view hierarchy changed in ios 8, (getmoretableviewcell*)[[[editbutton superview] superview] superview];
returns different view. easiest solution change number of superview calls ios 8. more reliable solution connect target getmoretableviewcell
.
Comments
Post a Comment