UITableView edit (insert, delete, move)

Source: Internet
Author: User

First of all two methods Beginupdates and Endupdates, a few points to note:

    • In general, we write the insertion, deletion, and movement of rows and blocks in a function block composed of these two methods. If you do not call insert, delete, and move methods in blocks of these two functions, the properties of the table (such as the number of rows) may be invalidated.
    • In general, you should not call Reloaddata in a function block consisting of these two functions, and if you do, then all animations should be done on your own.
    • These two methods consist of blocks that can be nested.
    • Insert, delete operations in the same block are processed before the delete operation executes the insert operation, regardless of their order in the block .

Whether the

UITableView is in edit mode depends on its editing property. When in edit mode, an INSERT or delete control appears on the left side of each cell, depending on how the cell is configured. Touching a control causes TableView to call the data source method tableview: Commiteditingstyle:forrowatindexpath:setediting: Animated: allows TableView to enter or exit the edit mode, the table's data source can have a selective deny cell into the edit pattern by implementing tableview:caneditrowatindexpath:.

when a tableview is in the edit state, its agent passestableView:editingStyleForRowAtIndexPath:返回每个可编辑的cell所处的状态(插入、删除)。当一个tableView收到setEditing:animated:消息时,它给每个每一个可见行的UITableViewCell对象发送相同的消息,接着它给数据源和代理发送一连串消息像下面图中描述的那样。

When the user swipe across a row to display the Delete button, there is a change in the order of calls in the diagram above. When the user swipe a row to be deleted, TableView first checks whether its data source implements the TableView:commitEditingStyle:forRowAtIndexPath: method, if implemented, TableView sends itself setediting:animated: message, into edit mode. In this "swipe to delete" mode, TableView does not display the edit and reorder controls. Because this is a user-driven event, it also brackets the messages to the delegate inside of two other messages tableView:willBeginEditingRowAtIndexPath: : andtableView:didEndEditingRowAtIndexPath:.(怎么翻译合适^.^)。通过实现这些方法,代理可以合适的更新tableView的外观。

"It's a little complicated behind me, I'll study."

UITableView edit (insert, delete, move)

Related Article

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.