刷卡不适用于ios sdk中的uitableview的单元格

时间:2014-04-12 06:24:55

标签: ios uitableview

我已经使用xib实现了customtableview单元格并在tableview中使用。下面是cellforrowatindexpath的代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *CellIdentifier=@"Cell Identifier";

    CustomInboxCell_Iphone *cell=(CustomInboxCell_Iphone *)[_tblView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(cell==nil)
    {
        if([appDelegate isIphone4]||[appDelegate isIphone5])
            cell=[[[NSBundle mainBundle] loadNibNamed:@"CustomInboxCell_Iphone" owner:self options:nil]objectAtIndex:0];
        else
            cell=[[[NSBundle mainBundle] loadNibNamed:@"CustomInboxCell_Ipad" owner:self options:nil]objectAtIndex:0];


        [cell.btnCheck addTarget:self action:@selector(btnCheckClicked:) forControlEvents:UIControlEventTouchUpInside];
    }

    cell.btnCheck.tag=indexPath.row;

    cell.lblMain.text=[NSString stringWithFormat:@"%@ %@",[[_arrList objectAtIndex:indexPath.row]valueForKey:@"first_name"],[[_arrList objectAtIndex:indexPath.row]valueForKey:@"last_name"]];

    if([appDelegate isIpad])
    {
        cell.lblMain.font=[UIFont boldSystemFontOfSize:25.0f];
    }

    _tblView.separatorColor=[UIColor grayColor];

    cell.lblDesc.text=[[_arrList objectAtIndex:indexPath.row]valueForKey:@"subject"];

    cell.lblTime.text=[[_arrList objectAtIndex:indexPath.row]valueForKey:@"send_date_from"];

    cell.btnCheck.selected=NO;

    if([_dictSelect count]>0)
    {
        NSNumber *temp=[_dictSelect valueForKey:[NSString stringWithFormat:@"%d",indexPath.row]];


        if(indexPath.row==[temp intValue] && temp!=nil)
            cell.btnCheck.selected=YES;
        else
            cell.btnCheck.selected=NO;
    }

    return cell;
}

并且还使用了

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationTop];

         [_dictSelect setValue:[NSString stringWithFormat:@"%d",indexPath.row] forKey:[NSString stringWithFormat:@"%d",indexPath.row]];

        [self btnDeleteClicked:nil];
    }
}

但我仍然无法滑动,这意味着当我触摸它被选中的单元格然后我移动我的手指一点然后它就会关闭&然后滑动不起作用,很少刷卡工作。

那么请问这个问题是否有任何建议/解决方案。

提前完成。

1 个答案:

答案 0 :(得分:0)

使用此功能并根据您修改....

这里_chat是一个数组

  -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
       // Return YES if you want the specified item to be editable.
    return YES;
   }

// Override to support editing the table view.
 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 if (editingStyle == UITableViewCellEditingStyleDelete) {
       [_chats removeObjectAtIndex:indexPath.row];
       [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
   }    
}