0

行を含むテーブル ビューがあります... 1 つの項目を選択した後、新しいデータ ソースで tableView を表示したいと考えています。

私は実装しようとしました:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[self.searchDisplayController setActive:YES animated:YES];
    Game *game = [self.filteredListContent objectAtIndex:indexPath.row];
    //name your class names with capitals
    NSMutableArray *arrayToBeAdded= [[NSMutableArray alloc]initWithArray:newgamearray];
    [ListContent removeAllObjects];
    [ListContent addObject:arrayToBeAdded];

しかし、私は例外を取得しています

[ListContent removeAllObjects];

初期化の実装:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellID = @"cellSgames";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];

    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID] autorelease];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    Gmage *game = [self.ListContent objectAtIndex:indexPath.row];

.h ファイルで次のように宣言します。

NSArray AllList;
NSMutableArray ListContent;

何か案は?

4

2 に答える 2

3

現在のリストを操作する代わりに、目的のデータ ソースで新しい UITableViewController を作成します。UINavigationController を使用している場合は、ユーザー エクスペリエンスが向上し、現在の問題を回避できます。

例:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    InnerTableViewController *innerTVC = [[InnerTableViewController alloc] initWithNibName:@"InnerTableViewController" bundle:nil];

    [self.navigationController pushViewController:innerTVC animated:YES];
    [innerTVC release];
}
于 2012-08-16T07:39:22.250 に答える
0

通常、didselect メソッドで配列をリセットし、テーブル ビューを新しいコンテンツでリロードする場合は、機能するはずです。

あなたの場合、次の行で考えます: [ListContent removeAllObjects];

ListContent は有効なポインターではありません。ここでクラッシュする理由がわかりません。

于 2012-08-16T09:20:31.533 に答える