iOS reordering a UITableView -
i have uitableview reads data sql db.
when reorder data changes top , bottom ones
dragging 1 top bottom
when let go @ 5 switches top , bottom ones.
using following
- (void)tableview:(uitableview *)tableview moverowatindexpath:(nsindexpath *)fromindexpath toindexpath:(nsindexpath *)toindexpath { [mystringsarray exchangeobjectatindex:fromindexpath.row withobjectatindex:toindexpath.row]; }
how can reorder list? it'll 2,3,4,5,1 , not 5,2,3,4,1
exchange not proper way should use this.
- (void)tableview:(uitableview *)tableview moverowatindexpath:(nsindexpath *)fromindexpath toindexpath:(nsindexpath *)toindexpath { id buffer = [mystringsarray objectatindex:fromindexpath.row]; [mystringsarray removeobjectatindex:fromindexpath.row]; [mystringsarray insertobject:buffer atindex:toindexpath.row]; }
edited match comment below.
Comments
Post a Comment