iphone - How to make UITableView rearrangeable? -


i'm trying make uitableview editable can move cells around. right when click edit button, lets me delete not re-arrange.

the methods have are:

code: - (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath {     return yes; }  - (void)setediting:(bool)editing animated:(bool)animate {     [self.routinetableview setediting: !self.routinetableview.editing animated:yes];      if (self.routinetableview.editing)         [self.navigationitem.leftbarbuttonitem settitle:@"done"];     else         [self.navigationitem.leftbarbuttonitem settitle:@"edit"]; }  -(void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath  {      if (editingstyle == uitableviewcelleditingstyledelete)       {          nsmanagedobjectcontext *context = [self.fetchedresultscontroller managedobjectcontext];          [context deleteobject:[self.fetchedresultscontroller objectatindexpath:indexpath]];          nslog(@"fetched results : \n%@\n",[self.fetchedresultscontroller fetchedobjects]);           nserror *error = nil;           if (![managedobjectcontext save:&error])           {              // handle error.          }     }  - (bool)tableview:(uitableview *)tableview canmoverowatindexpath:(nsindexpath *)indexpath {     return yes; } 

in order implement reordering rows correctly, table view data source should implement methods :

-(bool)tableview:(uitableview *)tableview canmoverowatindexpath:(nsindexpath *)indexpath; -(void)tableview:(uitableview *)tableview moverowatindexpath:(nsindexpath *)fromindexpath        toindexpath:(nsindexpath *)toindexpath; 

and delegate implement :

-(nsindexpath *)tableview:(uitableview *)tableview targetindexpathformovefromrowatindexpath:(nsindexpath *)sourceindexpath                      toproposedindexpath:(nsindexpath *)proposeddestinationindexpath; 

there page giving examples of code.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -