0

カスタムセルを備えた UITableView があります.Swipe-to-deleteはiPadシミュレーターではうまく機能しますが、iPadデバイスでは機能しませんでした.

これが私のコードです:

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

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

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView beginUpdates];
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        if(_itemsArray == nil)
            NSLog(@"\n\nNIL ARRAY\n\n");
        NSLog(@"\nindexPath.row = %d\nItemsArray Count:%d",indexPath.row,_itemsArray.count);
        int row = [[[_itemsArray objectAtIndex:indexPath.row]valueForKey:@"itemRow"] integerValue];
        [_itemsArray removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
        [[self delegate]didDeletedBillItemRow:row];
    }
    [tableView endUpdates];
}

また、カスタム セル コントローラーに layoutSubviews を実装しました。

-(void)layoutSubviews
{
    [super layoutSubviews];
} 

問題は何だと思いますか?

4

2 に答える 2

0

編集中の選択モードのプロパティを「編集中の複数選択」ではなく「編集中の単一選択」に変更しただけで、スワイプ削除を使用して行を完全に削除できるようになりました。

于 2014-06-19T10:57:00.557 に答える