0

我正在用這個故事板。在故事板上,我有一個「mainpage」uiviewcontroller,它有一個按鈕,當tap會調用另一個uiviewcontroller(choosewinner)彈出。但是這個選擇者vc擁有一個uinavigation控制器,爲什麼它可以輕鬆地來回移動。現在我可以調用uiview作爲模式彈出,但不顯示它的uinavigation。viewcontroller with uinvaigationcontroller when pop up does not show the navbar

這是在點擊按鈕時調用的方法。思考?

- (void)updateWinner{ 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 

    MatchWinnerViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WinnerViewController"]; 

    vc.modalPresentationStyle = UIModalPresentationFormSheet; 
    vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentViewController:vc animated:NO completion:nil]; 
    vc.view.superview.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 
    vc.view.superview.bounds = CGRectMake(0, 0, 800, 600); 
} 

回答

0

即使你有MatchWinnerViewControllerUINavigationController連接到它在故事板,如果你想與UINavigationController模態呈現它,你需要導航控制器作爲參數提供給方法instantiateViewControllerWithIdentifier

原因是對於模態表示,它需要根視圖控制器,導航控制器也是視圖控制器。