简体   繁体   中英

Rearrange UITableView sections, rows, and rows between sections

I am trying to accomplish the following 3 requirements:

  1. Display a UITableView that has sections of content.
  2. Be able to rearrange the rows of the table between sections.
  3. Be able to rearrange the sections, similar to how rearranging rows works.

(Also, I cannot use a UICollectionView )

I can currently do the first two without any problem. I've done iOS development for a while now, but I'm stumped on how to actually rearrange the sections, and make it appear as it would be if you were moving a row.

I've tried to make a nested table in a UITableViewCell , and pretend the first cell is a "header," but this only works for moving sections and breaks the ability to rearrange rows between sections (admittedly, I could be going about this wrong).

I realize this is a complex question, but any help would be appreciated - even if the answer is "can't be done."

I think you'll have to create something custom here, you won't be able to find some readymade section reordering functions. I dont know if this would help but here's a link to github project ( https://github.com/shusta/ReorderingTableViewController ) which tries to mimic the "rows reordering" feature provided by iOS in edit mode using gestures and custom animations and views. Maybe you can go through it and try to create something similar for sections. Hope this helps

I think that the only way to achieve a completely free row and section reordering is to build a fully custom UIView subclass that looks like a UITableView (or not, if you want) and go hard on gesture recognizers for repositioning. It won't be fast, but it's completely possible.

Aside from the problem of creating this rather complex table thing, perhaps there is another way to solve your current problem, one that is less troublesome.

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