0

xCode4.2を使用してiPhoneアプリを作成しています。

関連する質問 -これは私が経験している本当の問題かもしれないと思います :tableView dequeueReusableCellWithIdentifier:CellIdentifierがnullを返すのはなぜですか?

しかし、とにかくこの質問を続けさせてください:

[[NSBundle mainBundle] loadNibNamed:@"WSCSessionCell" owner:nil options:nil];ルートビューコントローラーを特定の方法でセットアップしたときにSIGABRTエラーが発生する行には、別の方法ではなく何かがあります。UITableViewControllerを継承するWSCSessionTableのサンプルコードから始めましょう。

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

    WSCSessionCell *cell = (WSCSessionCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"WSCSessionCell" owner:nil options:nil];

        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[UITableView class]])
            {
                cell = (WSCSessionCell *) currentObject;
                break;
            }
        }

    }
return cell;
}

シナリオ1-問題なし-SIGABRTなし

上記のコードは、NavigationControllerrootviewcontrolsWSCSessionTableの場合に正常に機能します。参考までに、私のストーリーボードは次のようになります。 WSCSessionTableへのナビゲーションコントローラー

シナリオ2-問題、コードがSIGABRTを引き起こす

上記のコードは、ナビゲーションコントローラーとWSCSessionTableの間にUIViewControllerを配置すると、SIGABRTエラーを引き起こします。次に、ボタンを使用してWSCSessionTableをインスタンス化します。これが私のストーリーボードのセットアップです

ボタンタップでWSCSessionをアクティブ化

これはボタンのイベントハンドラーです

- (IBAction)goToSession:(id)sender
{
    wscAppDelegate *appDelegate = (wscAppDelegate *)[[UIApplication sharedApplication] delegate];
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
    wscSessions *childView = [storyboard instantiateViewControllerWithIdentifier:@"sessionstable"];
//    wscSessions *childView = [storyboard instantiateViewControllerWithIdentifier:@"sessionstable"];
    childView._arrData = appDelegate._arrSession;
    childView._arrSpeaker = appDelegate._arrSpeaker;
    childView.title = @"SEssions";
    [self.navigationController pushViewController:childView animated:YES]; 
    }

nsbundlemainbundleの行のcellforrowatindexpath関数でsigabrtエラーが発生します。これがエラー出力です

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/dduvernet/Library/Application Support/iPhone Simulator/5.1/Applications/54EF04FD-E010-48BB-A0F4-EB0F12BF8D6A/gmmiphone.app> (loaded)' with name 'WSCSessionCell''
*** First throw call stack:
(0x1da1022 0x2359cd6 0x1d49a48 0x1d499b9 0xa98638 0xa99eb7 0x3d9f 0x911c54 0x9123ce 0x8fdcbd 0x90c6f1 0x8b5d21 0x1da2e42 0x181679 0x18b579 0x1104f7 0x1123f6 0x111ad0 0x1d7599e 0x1d0c640 0x1cd84c6 0x1cd7d84 0x1cd7c9b 0x28f07d8 0x28f088a 0x877626 0x2138 0x2095 0x1)
terminate called throwing an exception(gdb) 

ボタンタブを押してWSCSessiontableをインスタンス化する方法を知っている人はいますか?

関連する質問 -これは私が経験している本当の問題かもしれないと思います :tableView dequeueReusableCellWithIdentifier:CellIdentifierがnullを返すのはなぜですか?

4

1 に答える 1

1

問題の一部は、UITableViewCell ではなく UITableView を検索していることです。

于 2012-05-25T20:03:41.230 に答える