objective c - TableViewCell subviews can't access in IOS 7 -


i using customized tableviewcell in app. works fine ios 6 got error in ios 7. error occurred when access sub views of uitableviewcell

see code below got error

- (void)addbuttonclicked:(uibutton *)button {      product *product = [productsarray objectatindex:button.tag];     nsstring *code = product.code;     otatablecell *cell = (otatablecell *) [[button superview] superview];      cell.pricelabel; // here error  } 

error shown is:

-[uitableviewcellscrollview pricelabel]: unrecognized selector sent instance 0x15d0ff80 

please me solve problem. in advance.

need 1 more superview call:

 otatablecell *cell = (otatablecell *)[[[button superview] superview] superview]; 

you can check like:

for ios >= 7:

       nslog(@"%@",[[sender superview] class]);   //uitableviewcellcontentview        nslog(@"%@",[[[sender superview] superview] class]); //uitableviewcellscrollview        nslog(@"%@",[[[[sender superview]superview]superview] class]);  //uitableviewcell 

for ios < 7:

       nslog(@"%@",[[sender superview] class]);   //uitableviewcellcontentview        nslog(@"%@",[[[sender superview] superview] class]); //uitableviewcell        nslog(@"%@",[[[[sender superview]superview]superview] class]);  //uitableview 

edit:if don't want rely on superview property:

uibutton *button = (uibutton *)sender; cgrect buttonframe = [button convertrect:button.bounds toview:self.table]; nsindexpath *indexpath = [self.table indexpathforrowatpoint:buttonframe.origin]; 

//access cell using indexpath:

uitableviewcell *cell=[self.table cellforrowatindexpath:indexpath];    cell.label=@"settext"; 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -