objective c - UITableView -cell buttons not showing up -


at 1 point cell buttons showing when scroll view wider. made smaller , buttons have disappeared. i've played around frame doesn't seem work. suggestions?

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {  static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) {     cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]autorelease];          uibutton*button= [uibutton buttonwithtype:uibuttontypecustom];         button.frame = cgrectmake(10.0, 0.0, 20,20);         [button settitle:@"tap" forstate:uicontrolstatenormal];     button.backgroundcolor= [uicolor blackcolor];          [button addtarget:self action:@selector(buttontapped:) forcontrolevents:uicontroleventtouchupinside];         cell.accessoryview = button;        [cell.contentview addsubview:button];  }  nsstring *cellvalue = [selection objectatindex:indexpath.row]; cell.textlabel.text = cellvalue;  return cell; 

you have implement custom button outside if condition u wrote. have write - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath method below:

 - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring * cellidentifier = @"cell";  uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier: cellidentifier];  if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier: cellidentifier]; }  //custom button outside if condition  uibutton*button= [uibutton buttonwithtype:uibuttontypecustom]; button.frame = cgrectmake(10.0, 0.0, 20,20); [button settitle:@"tap" forstate:uicontrolstatenormal]; button.backgroundcolor= [uicolor blackcolor]; [button addtarget:self action:@selector(buttontapped:) forcontrolevents:uicontroleventtouchupinside]; cell.accessoryview = button; [cell.contentview addsubview:button];  return cell;   

}


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -