UITableView How to undo a move operation

Source: Internet
Author: User

Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)

We know that using UITableView's delegate method Canmoverowatindexpath can determine whether a row of cells can be moved, that is, whether the source cell can be moved, but if we want to control whether it can be moved to the target index?

One idea is to determine the target index in Moverowatindexpath: If not allowed to move, then do the reverse action, that is, delete the cell at the destination index position and then add it back to the source index.

However, this cannot be achieved because the source cell has not been moved to the destination index, so it cannot be deleted. But Moverowatindexpath: After the method is finished, the control of the mobile operation is lost.

In fact, there is a simple way, if you do not want to make the move operation, including any need to change the interface, you simply re-refresh the TableView view. Because your underlying data is not changed, the interface will not change after refreshing the view, which is equivalent to undoing the move operation, And there are animation effects:

As shown above we prohibit the move of the Add cell and prohibit any other cell from moving to the back of the Add cell, which is to ensure that the add cell is always in the last row of the view.

UITableView How to undo a move operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.