質問

Three20は偉大なライブラリです。これは、テーブルと作業が非常に簡単になっています。しかし、私は気づいた1つのギャップは - アニメーションを持つ行の削除、です。私はこれをやろうとしている多くの時間を費やしたが、これは私がやっているものです。

// get current index patch
UITableView* table = [super tableView];
NSIndexPath *indexPath = [table indexPathForSelectedRow];

//delete row in data source
TTListDataSource * source = (TTListDataSource *)self.dataSource;
[source.items removeObjectAtIndex:indexPath.row]; 

// delete row from the table, with animation
[table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

このコードが実行された後、エラーが表示されます[NSCFArray objectAtIndex:]:インデックス(0)を越えて境界(0)

私はTTTableViewControllerから継承したクラスを使用しています。私はできるだけThree20を使用していますので、私はDataSourceDelegateまたはTableViewDelegateを実装していません。だから、これは私がデータソースを作成する方法です。

for(NSDictionary *album in (NSArray *)albums){

TTTableRightImageItem *item = [TTTableRightImageItem itemWithText:@"name"  
            imageURL:@"image url" 
           defaultImage:nil 
          imageStyle:TTSTYLE(rounded)
           URL:@"url of selector where I actually catch the tap on a row"];
[tableItems addObject:item];
}
self.dataSource = [TTListDataSource dataSourceWithItems:tableItems];

私はこの記事(記事を)読んで、それ助けにはならない:(

だから、私は、これは、このサイトからの教祖のための非常にシンプルであることを知っています。あなただけの私にこれを行う方法の高度なサンプルを与えることができます。

おかげ

役に立ちましたか?

解決

私はスポット最初の事は、テーブルが編集モードでないときに、テーブルから行を削除しているということです。

他のヒント

私もmodel:didDeleteObject:atIndexPath:で「EXC_BAD_ACCESS」を得たが、私はその問題解決を得ています。

あなたはこのようなあなたのDataSource実装にtableView:commitEditingStyle:を実装する必要がTTTableViewControllerの行を削除するには:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
        forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        id object = [[self.items objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];

        [self.model didDeleteObject:object atIndexPath:indexPath];
    }
}

あなたはまた、あなたのデータソースにtableView:willRemoveObject:atIndexPath:を実装する必要があります:

- (NSIndexPath*) tableView:(UITableView *)tableView willRemoveObject:(id)object atIndexPath:(NSIndexPath *)indexPath {
    // delete the object
    [object deleteFromDB];

    // removeItemAtIndexPath returns YES if the section is removed
    if ([self removeItemAtIndexPath:indexPath andSectionIfEmpty:YES]) {
        // remove an index path only to that section
        return [NSIndexPath indexPathWithIndex:indexPath.section];
    } else {
        return indexPath;
    }
}

トリックは、それが空になるのセクションが含まれているだけに戻りNSIndexPathを変更することです。次いでTTTableViewControllerのコードではなく、セルのセクションを除去します。

HTH

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top