首页 > 其他 > 详细

tableview 编辑状态设置

时间:2015-03-24 10:36:06      阅读:291      评论:0      收藏:0      [点我收藏+]
#pragma mark - tableview 编辑状态设置
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
           editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleDelete;
}

-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return @"删除";
}


-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"编辑操作");
    if (editingStyle == UITableViewCellEditingStyleDelete) {
//        NSUInteger row = [indexPath row];
//        [self.dataArray removeObjectAtIndex:row];
        NSMutableDictionary * dics = [self.dataDictionary objectForKey:KEY_SECTION(indexPath.section)];
         CELL_STRUCT * cellstruct = [dics objectForKey:KEY_INDEXPATH(indexPath.section, indexPath.row)];
         PengChanelChat *pcc = (PengChanelChat *)cellstruct.object;
        [[MIChatModel sharedInstance] removeOneChaterNoSignal:[NSString stringWithFormat:@"%@",pcc.m_cid]];
        [dics removeObjectForKey:KEY_INDEXPATH(indexPath.section, indexPath.row)];
        [self.dataDictionary setObject:dics forKey:KEY_SECTION(indexPath.section)];
        
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}

  

tableview 编辑状态设置

原文:http://www.cnblogs.com/nonato/p/4361984.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!