码迷,mamicode.com
首页 > 其他好文 > 详细

UITableViewDelegate实现方法commitEditingStyle:forRowAtIndexPath

时间:2015-09-17 10:11:57      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:


- tableView:commitEditingStyle:forRowAtIndexPath:
Asks the data source to commit the insertion or deletion of a specified row in the receiver.

Declaration声明
SWIFT
optional func tableView(_ tableView: UITableView,
     commitEditingStyle editingStyle: UITableViewCellEditingStyle,
      forRowAtIndexPath indexPath: NSIndexPath)
OBJECTIVE-C
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
Parameters参数
tableView   
The table-view object requesting the insertion or deletion.
editingStyle   
The cell editing style corresponding to a insertion or deletion requested for the row specified by indexPath. Possible editing styles are UITableViewCellEditingStyleInsert or UITableViewCellEditingStyleDelete.
indexPath   
An index path locating the row in tableView.
Discussion
When users tap the insertion (green plus) control or Delete button associated with a UITableViewCell object in the table view, the table view sends this message to the data source, asking it to commit the change. (If the user taps the deletion (red minus) control, the table view then displays the Delete button to get confirmation.) The data source commits the insertion or deletion by invoking the UITableView methods insertRowsAtIndexPaths:withRowAnimation: or deleteRowsAtIndexPaths:withRowAnimation:, as appropriate.

To enable the swipe-to-delete feature of table views (wherein a user swipes horizontally across a row to display a Delete button), you must implement this method.

You should not call setEditing:animated: within an implementation of this method. If for some reason you must, invoke it after a delay by using the performSelector:withObject:afterDelay: method.

Import Statement
OBJECTIVE-C
@import UIKit;
SWIFT
import UIKit

UITableViewDelegate实现方法commitEditingStyle:forRowAtIndexPath

标签:

原文地址:http://www.cnblogs.com/wenios/p/4815371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!