Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:47:32+00:00 2026-06-13T21:47:32+00:00

The UITableView documentation says that it’s OK to combine calls to moveSection:toSection: , insertSections:withRowAnimation:

  • 0

The UITableView documentation says that it’s OK to combine calls to moveSection:toSection:, insertSections:withRowAnimation:, and deleteSections:withRowAnimation: in a beginUpdates–endUpdates block. A section called Batch Insertion, Deletion, and Reloading of Rows and Sections in the Table View Programming Guide also explains that when mixing inserts and deletes inside an update block, the table view does the deletions before it does the insertions no matter what order the method calls are made in.

My question is, when calls to moveSection:toSection: are combined with calls to insertSections: and deleteSections:, in what order does the table view do the moves? Or alternatively, do the fromSection and toSection refer to the section indices before the deletes, between the deletes and inserts, or after the inserts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:47:34+00:00Added an answer on June 13, 2026 at 9:47 pm

    After experimenting with some code, it appears that the best way to think about a batch of changes inside a beginUpdates–endUpdates block is terms of the order of the sections before any of the updates are applied and the order of sections after all of the updates are applied. If U represents the order before the update block and V the order after update block, then the section indices used in the deleteSections: calls and the source indices in the moveSection:toSection: are the indices in U and the section indices used in the insertSections: and the destination indices in the moveSection:toSection: calls are the indices in V.

    So, for example, to animate the changes:

      0   C   ->   A   0
      1   F        H   1
      2   H        C   2
      3   K        K   3
    

    you could use:

    [tableView deleteSections:@[1] withRowAnimation:UITableViewRowAnimationAutomatic]; // delete F
    [tableView insertSections:@[0] withRowAnimation:UITableViewRowAnimationAutomatic]; // insert A
    [tableView moveSection:2 toSection:1]; // move H
    [tableView moveSection:0 toSection:2]; // move C (implied by other changes so not necessary)
    

    If some set of moves are implied by the other changes that are made, it is not necessary to explicitly make them. For example to rotate section A to the bottom of the table:

      0   A   ->   B  0
      1   B        C  1
      2   C        D  2
      3   D        A  3
    

    the following are logically equivalent:

    [tableView moveSection:0 toSection:3];
    

    and

    [tableView moveSection:1 toSection:0];
    [tableView moveSection:2 toSection:1];
    [tableView moveSection:3 toSection:2];
    

    However they are animated slightly differently. In the first case, section A is animated moving down over the others, while in the second case the three sections moving up are animated over section A.

    Finally, it appears that when animating a set of changes that involves some sections that move down and others that move up, the sections that don’t move are on the bottom, the sections that move down are above them, and the sections that move up are on top.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problems using this UITableView method : - (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation First the
UITableView allows you to batch editing operations using beginUpdates and endUpdates . My question
In the FRC documentation, it says that it is intended to efficiently manage the
From the documentation of UITableView / UITableViewController: If you decide to use a UIViewController
Apple's documentation on UITableView discusses how to add/edit/delete rows, but it doesn't discuss adding/editing/deleting
I can't seem to find good documentation that will allow me to do the
I have a UITableView with custom cells that were defined in the xib file,
I'm currently trying to implement a UITableView with a delegate and data source that
I've created a nib for a custom UITableView cell and followed the documentation and
The documentation for the NSFetchedResultsController states that it is intended for use to 'efficiently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.