在ModalViewController中使用UINavigation控制器的问题

时间:2012-10-20 04:22:59

标签: uinavigationcontroller uimodalpresentationstyle

我试图从另一个UIViewController以模态方式呈现UINavigationController的根视图。但是,当我单击触发模态转换的按钮时,我得到一个空UINavBar的空白屏幕。我怀疑我没有将视图附加到UINavigationController,但我不确定如何做到这一点。

这是我对应该触发模态转换的target-action方法的代码。此代码包含在模态演示者的实现文件中:

    //Instansiate the root UIViewController 

        OzSoundSelectionViewController *selectionView = [[OzSoundSelectionViewController alloc]initWithNibName:@"OzSoundSelectionViewController" bundle:nil];

//Instansiate the UINavigatonController and set the root view controller

        navigationController = [[UINavigationController alloc]initWithRootViewController:selectionView];

//Set up the modal transition
        [selectionView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
        [self presentModalViewController:navigationController animated:YES];

1 个答案:

答案 0 :(得分:0)

我弄明白了这个问题。

我在rootViewController中声明了一个名为navigationController的属性。这覆盖了属性navigationController,它是UIViewController父类的一部分。这搞砸了一切。