最新国产好看的视频,伊人天堂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)論

册亨县| 紫阳县| 曲阳县| 汉川市| 桂平市| 桑日县| 济源市| 焉耆| 河间市| 遂昌县| 明溪县| 白水县| 新疆| 青海省| 堆龙德庆县| 诸城市| 道真| 禹州市| 承德县| 景谷| 阳泉市| 南溪县| 视频| 凤翔县| 井研县| 清水县| 焦作市| 临高县| 鹿泉市| 内江市| 凤翔县| 清水河县| 宁武县| 视频| 榆树市| 冀州市| 华宁县| 临武县| 定南县| 三门峡市| 垫江县|