Uitableview-delete data

Source: Internet
Author: User

1. uitableview editing mode

# Set proxy for Pragma mark to implement proxy Protocol

# Pragma mark-proxy method # If Pragma mark implements this method, it will implement the sorting function-(void) tableview :( uitableview *) tableview moverowatindexpath :( nsindexpath *) sourceindexpath toindexpath :( nsindexpath *) destinationindexpath {// 1. retrieve the model data person * P = _ persons [sourceindexpath. row]; // 2. delete model data from the original location [_ persons removeobject: p]; // 3. insert the retrieved model data into the new location [_ persons insertobject: P atindex: destinationindexpath. row] ;}# Pragma mark when the user submits a compilation operation Call (for example, click the "delete" button) and so on // as long as this method is implemented, the sliding delete function is implemented by default-(void) tableview :( uitableview *) tableview commiteditingstyle :( uitableviewcelleditingstyle) editingstyle forrowatindexpath :( nsindexpath *) indexpath {// if it is not a delete operation, return if (editingstyle! = Uitableviewcelleditingstyledelete) return; // 1. delete model data [_ persons removeobjectatindex: indexpath. row]; // 2. refresh data [_ tableview deleterowsatindexpaths: @ [indexpath] withrowanimation: uitableviewrowanimationleft];} # pragma mark-delete-(void) Remove {// enter the compiling mode bool result =! _ Tableview. editing; [_ tableview setediting: Result animated: Yes];}

 

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.