iphone - UITableview not reloading after UIAlertview -
after entering new item, in delegate method uialertview
, call reloaddata
of uitableview
, not being updated:
- (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { // if row deleted, remove list. if (editingstyle == uitableviewcelleditingstyledelete) { if (indexpath.row > 0) { [datcontroller removedata:indexpath.row-1]; [tableview deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade]; } } else if(editingstyle == uitableviewcelleditingstyleinsert) { uialertview *myalertview = [[uialertview alloc] initwithtitle:@"enter item." message:@"" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles:@"ok",nil]; flditem = [[uitextfield alloc] initwithframe:cgrectmake(12.0, 45.0, 260.0, 25.0)]; [flditem setbackgroundcolor:[uicolor whitecolor]]; [myalertview addsubview:flditem]; [tableview reloaddata]; [myalertview show]; [myalertview release]; } } - (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { if(buttonindex == 0){} else { [datcontroller adddata:flditem.text]; [self.tableview reloaddata]; } }
note reloaddata
in method commiteditingstyle
, put in debugging purposes only, , place it's working.
method cellforrowatindexpath
redraws tableview, not fired after execute reloaddata
:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { //try rusable (rusable) cell uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cellidentifier"]; if (cell == nil) { //if not possible create new cell cell = [[[uitableviewcell alloc] initwithframe:cgrectmake(0,0,0,0) reuseidentifier:@"cellidentifier"] autorelease]; cell.accessorytype = uitableviewcellaccessorydisclosureindicator; } // string display , set value in cell if(indexpath.row == 0) { cell.textlabel.text = @"add items..."; } else { cell.textlabel.text = [datcontroller listdata:indexpath.row-1]; } return cell; }
not sure have gone wrong end in situation, sure self.view
not nil?
in place reloaddata
call working you're using tableview
reference passed , not self.view
, call isn't working using self.view
. code above that's obvious thing noticed far.
Comments
Post a Comment