[Rookie growth Kee]ios Development Self-study note 03-uitableview Primary advanced cell deletion

Source: Internet
Author: User

The previous section implements a simple table view interface, including some custom interface elements, based on the custom UITableView table view cell. Apple's products, from iphone to Mac, offer a wide variety of gestures to show the user's user-friendliness, and in the table view cells such as "mail", each cell slides left to the right to remove buttons to make it easier for users to quickly delete a selected row. In fact, it is not difficult to implement this function, only need to implement the method in the Uitableviewdatasource protocol in Viewcontroller

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

Even if nothing is done in the method definition, the Delete button appears when the cell slides to the left.

But I initially added the above method in the program empty Declaration, swipe to the left but did not appear the imagined "delete" button, after several twists and turns finally found that the original is Main.storyboard selected AutoLayout constraint error, resulting in the program run the rightmost delete button is actually "hidden" Out of the screen. Workaround: Control-click the TableView drag box in the Main.storyborad viewcontroller click to select equal width and equal height to create a constraint that completely displays the contents of the table on the device screen. You can also see the delete button.

This is not the end of the matter, just to show the delete button is not enough, if you really need to click the corresponding delete button to delete the selected cells, but also in the above method to implement a specific delete operation, that is, action on the background data, such as:

    [Clubname RemoveObjectAtIndex:indexPath.row];    [Clublogo RemoveObjectAtIndex:indexPath.row];    [Clubrank RemoveObjectAtIndex:indexPath.row];        [TableView Reloaddata];

and reload the table view to correctly display the effect of the deletion.

[Rookie growth Kee]ios Development Self-study note 03-uitableview Primary advanced cell deletion

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.