Edit Delete line method for Iosuitableview

Source: Internet
Author: User

(edit added on Navigationbar)

Edit---Complete

-(void) bianji{

if (Self.tableview.isediting==no) {

[Self.tableview setediting:yes animated:yes];

UIImage *imagetmp=[uiimage imagenamed:@ "Baoxun_01.png"];

[Self.btn setimage:imagetmp Forstate:uicontrolstatenormal];

} else {

[Self.tableview setediting:no animated:yes];

UIImage *imagetmp=[uiimage imagenamed:@ "Bianji_01.png"];

[Self.btn setimage:imagetmp Forstate:uicontrolstatenormal];

}

[Self.tableview Reloaddata];

}


-(void) TableView: (UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath: (Nsindexpath *) Indexpath {

if (Editingstyle = = Uitableviewcelleditingstyledelete) {

Remove rows from an array

[MyData RemoveObjectAtIndex:indexPath.row];

Table View Remove rows

[Self.tableview Deleterowsatindexpaths:[nsarray Arraywithobject:indexpath] Withrowanimation: Uitableviewrowanimationfade];

Delete the local file if you do not have the following code removed

Nsarray *paths = Nssearchpathfordirectoriesindomains (Nsdocumentdirectory,nsuserdomainmask,yes);

NSString *path = [Paths objectatindex:0];

NSString *filename = [path stringbyappendingpathcomponent:@ "Shoucang.plist"];

Nsmutablearray *array = [[[Nsmutablearray alloc] initwithcontentsoffile:filename]autorelease];

[Array RemoveObjectAtIndex:indexPath.row];

[Array writetofile:filename atomically:yes];

}

}

Edit Delete line method for Iosuitableview

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.