1

簡単なビュー切り替え機能を作ってみたのですがうまくいきませんでした。問題は、私self.navigationControlernil. どうすれば修正できますか?

ViewController2 *hs=[self.storyboard instantiateViewControllerWithIdentifier:@"Highscore"];
if(self.navigationController==nil)
{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"YOur Message" message:@"Your description"
                                                   delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
    [alert show];
}


    [self.navigationController pushViewController:hs animated:YES]; 
4

1 に答える 1

0

UINavigationController から現在のビュー コントローラーを提示する必要があります。

UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:Your_Current_View_Controller];

//Now present controller in any way you want

その後、あなたの self.navigationController はもう nil ではありません

于 2012-06-07T09:44:53.207 に答える