简体   繁体   中英

iPhone: UITableView reorder rows

There is an edit mode in UITableView which gives user possibility to reorder rows. To reorder rows user should click and drag on edit button (3 stripes). Is there any possibility to reorder rows also when user touch on row at all, not only on edit button ??? Thanks...

You can programmatically reorder rows (and in iOS 5 you can also reorder entire sections). You would just need to know where the user intends to move the row/section to based on the single tap. You need to use the methods

- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath

or

- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection

respectively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM