2

ボタンなしでView Controllerをロードしたい。識別子を10に設定して使用しようとしました

if(...){ 
    //load ViewController2
    [[self storyboard] instantiateViewControllerWithIdentifier:@"10"];
}

しかし、何も起こりません。

この機能では、それも機能しs doesnます

 UIViewController *vc = [[self storyboard] instantiateViewControllerWithIdentifier:@"10"];

[self.navigationController pushViewController:vc];

ここに私のプロジェクトがあり ます http://www.sendspace.com/file/kfjhd5

何が問題なの?

4

1 に答える 1

1

それが言うように、呼び出すinstantiateViewControllerWithIdentifier:とView Controllerがインスタンス化されます。これ以上何もない。実際に表示したい場合は、変数を使用してView Controllerスタックにプッシュする必要があります。

UIViewController *vc = [[self storyboard] instantiateViewControllerWithIdentifier:@"10"];
[self.navigationController pushViewController:vc];

もちろん、UINavigationControllerこれを行うには a を使用する必要があります。

于 2012-09-18T16:18:23.063 に答える