【发布时间】:2015-03-16 10:21:46
【问题描述】:
我在使用简单的 Xamarin Studio Storyboards 概念时遇到了问题。请参阅下面的屏幕截图以获取视觉效果,并查看downloadable source code here。
假设我有一个带有 MainViewController 的 NavigationController。这在我的故事板中可见。我想要一个按钮,当按下它时,会弹出一个带有 RedViewController 的新 NavigationController。我还希望 RedViewController 在与 MainViewController 相同的情节提要上。在这个项目中,我尝试这样做,但出于某种原因,当我这样做时:
var myStoryboard = AppDelegate.Storyboard;
// Instatiating View Controller with Storyboard ID 'StuffViewController'
RedViewController = myStoryboard.InstantiateViewController ("RedViewController") as RedViewController;
RedViewController.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
this.PresentViewController(RedViewController, true, null);
RedViewController 没有它的导航控制器。出现时 RedViewController 的导航控制器为空!我在那里做错了什么?
现在,当我在完全独立的情节提要中创建 NavigationController 和 BlueViewController 时,它可以正常工作。当我按下蓝色按钮时,它会转到 BlueViewController 并正确显示它是 NavigationController。为什么这个工作,而另一个不工作?我能看到的唯一区别是它们位于不同的故事板上。
UIStoryboard storyBoard = UIStoryboard.FromName ("BlueStoryboard", null);
UIViewController controller = storyBoard.InstantiateInitialViewController () as UIViewController;
controller.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
this.PresentViewController (controller, true, null);
ViewController 可以呈现一个新的 NavigationController 和 ViewController ViewController,名为“Red”,带有导航栏
【问题讨论】:
标签: ios uinavigationcontroller xamarin.ios xamarin storyboard