4

動的セルがUITableViewControllerあり、誰かがセルをタップしたときに特定のViewControllerをプッシュしたいと思います。だから私は既成の方法を使おうとしています

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

しかし、シミュレーターに入ってセルをタップすると、次のようになります。

"NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle [...] with name 'AffichageVotesQuestionDuMomentViewController'.

メソッド内で、私はこれを持っています:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.

     AffichageVotesQuestionDuMomentViewController *detailViewController = [[AffichageVotesQuestionDuMomentViewController alloc] initWithNibName:@"AffichageVotesQuestionDuMomentViewController" bundle:nil];

    // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];

}

AffichageVotesQuestionDuMomentViewController自分で作成したカスタムビューコントローラです。また、別のランダムなものを作成しようとしましたが、同じタイプのエラーが発生します。に設定するinitWithNibName:nil、ナビゲーションバーが上部にあるビューコントローラーになりますが、完全に黒です。

今、私は初心者のiPhoneプログラマーであり、ペン先やペン先の名前などについての理解が非常に乏しいです。どんな助けでも大歓迎です。また、プログラムでView Controllerを作成し、そのようにプッシュしているように見えるため、ストーリーボードなどでセグエを実行しませんでした。セグエでそれを行う良い方法があれば、私もそれで大丈夫です(しかし、タップされたセルの行を知る必要があります)。

ありがとうございました!

4

1 に答える 1

5

IBストーリーボードを使用しているので、次のようなことをする必要があります。

UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"mystoryboard" bundle:nil];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"AffichageVotesQuestionDuMomentViewController"];

...「initWithNibName」を使用する代わりに-従来のxibベースのアプローチに使用される初期化子。

于 2012-11-25T11:10:12.590 に答える