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