Fourth Chapter Sliding Delete

Source: Internet
Author: User
Tags set background

This project is the "beginning iOS8 programming with Swift" project learning note = = "All Notes directory

--------------------------------------------------------------------------------------------------------------- ---

1. Implement the following method to automatically turn on the swipe delete feature:

Override func TableView (Tableview:uitableview, Commiteditingstyle Editingstyle:uitableviewcelleditingstyle, Forrowatindexpath indexpath:nsindexpath) {}

2. Customize right-sliding menu items

OverrideFunc TableView (Tableview:uitableview, Editactionsforrowatindexpath indexpath:nsindexpath), [Anyobject]? {    //Share ItemsLet shareaction = Uitableviewrowaction (style:. Default, Title:"Share") {(action, indexpath), Voidinch        //choose a goal to shareLet Sharemenu = Uialertcontroller (title:nil, message:"Share using", Preferredstyle:. Actionsheet) Let Twitteraction= Uialertaction (title:"Twitter", Style:. Default, Handler:nil) let Facebookaction= Uialertaction (title:"Facebook", Style:. Default, Handler:nil) let Emailaction= Uialertaction (title:"Emain", Style:. Default, Handler:nil) let Cancelaction= Uialertaction (title:"Cancel", Style:. Cancel, Handler:nil) sharemenu.addaction (twitteraction) sharemenu.addaction (facebookaction) s Haremenu.addaction (emailaction) sharemenu.addaction (cancelaction) Self.presentviewcontroller (shareMen U, Animated:true, Completion:nil)} //Delete Item (Implementation of this method requires that you write the delete item yourself)Let deleteaction = Uitableviewrowaction (style:. Default, Title:"Delete") {(action, indexpath), Voidinch        //Delete from the data source// ...self.tableView.deleteRowsAtIndexPaths ([Indexpath], withrowanimation:. Fade)}//Set Background colorShareaction.backgroundcolor =Uicolor.orangecolor () Deleteaction.backgroundcolor=Uicolor.bluecolor ()return[ShareAction, Deleteaction]}

Fourth Chapter Sliding Delete

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.