- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
//UITableView的自定義滑動(dòng)模塊初始化
UITableViewRowAction *name = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"刪除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
//初始化警告控制中心
/*
typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {
UIAlertControllerStyleActionSheet = 0,//在app底下彈起
UIAlertControllerStyleAlert//在app屏幕中央出現(xiàn)
};
*/
UIAlertController *alert =[UIAlertController alertControllerWithTitle:@"刪除" message:@"確定刪除嗎" preferredStyle:UIAlertControllerStyleAlert];
//彈出框按鈕
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
//將彈出框按鈕添加到控制中心
[alert addAction:alertAction];
//顯示彈出控制中心
[self presentViewController:alert animated:YES completion:nil];
}];
//自定義返回的是一個(gè)不可變數(shù)組
NSArray *array = @[name];
return array;
}
效果, ok按鈕沒有做其他動(dòng)作
2016-04-13 at 下午10.42.gif