最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS實(shí)現(xiàn)UITableView左滑刪除復(fù)制即用功能

 更新時(shí)間:2017年09月20日 11:16:21   作者:Fantasy_Jun  
這篇文章主要介紹了iOS實(shí)現(xiàn)UITableView左滑刪除復(fù)制即用功能,在項(xiàng)目開(kāi)發(fā)中經(jīng)常會(huì)用到這樣的需求,下面小編把實(shí)現(xiàn)代碼分享給大家,需要的朋友可以參考下

開(kāi)發(fā)項(xiàng)目時(shí)候需要用到tableview左滑刪除,就研究了一下,話不多說(shuō)直接上代碼

//設(shè)Cell可編輯
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
  return YES;
}
//設(shè)置刪除按鈕
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
  return UITableViewCellEditingStyleDelete;
}
//進(jìn)入編輯(刪除)模式
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{  
  //出現(xiàn)alterView隱藏刪除按鈕
  [tableView setEditing:NO animated:YES];
  if (editingStyle == UITableViewCellEditingStyleDelete) {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"你確定刪除該消息?" preferredStyle:UIAlertControllerStyleAlert];
    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
      //需要先刪除數(shù)據(jù)源中對(duì)應(yīng)數(shù)據(jù),不然執(zhí)行下一步會(huì)崩潰
      [reconnaissanceListArr removeObjectAtIndex:indexPath.row];
      [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }]];
    [self presentViewController:alertController animated:YES completion:nil];
  }
}
//修改編輯按鈕文字
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
  return @"刪除";
}
//設(shè)置進(jìn)入編輯狀態(tài)時(shí),Cell不會(huì)縮進(jìn)
- (BOOL)tableView: (UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
  return NO;
}

總結(jié)

以上所述是小編給大家介紹的iOS實(shí)現(xiàn)UITableView左滑刪除復(fù)制即用功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論

兖州市| 吴桥县| 资阳市| 肇州县| 拜城县| 广汉市| 轮台县| 文昌市| 元谋县| 临武县| 依安县| 八宿县| 宜兴市| 丹阳市| 珠海市| 北碚区| 卢氏县| 德阳市| 湘阴县| 武城县| 毕节市| 辰溪县| 峨山| 德庆县| 永城市| 龙江县| 道孚县| 锡林郭勒盟| 若尔盖县| 梅州市| 托克逊县| 胶南市| 蓝山县| 宜都市| 桐乡市| 常德市| 台前县| 满洲里市| 扬州市| 玉环县| 都江堰市|