問題描述
我的 iOS 5 應用程序中有一個 Storyboard.
I have a Storyboard in my iOS 5 application.
在那里我創建了許多屏幕,并且效果很好.
In there I have created a number of screens and it works perfectly.
但是,我在代碼中創建了一個視圖控制器,不是作為 UI 操作的結果,而是在處理數據結束時.然后,我想將這個視圖控制器顯示為 modalViewController,但也要在情節提要編輯器中設計它.
However there's one view controller that I create in code, not as a result of UI action but at the end of processing data. I would like to show this view controller then, as a modalViewController, but also have it designed in the storyboard editor.
有可能嗎?使用筆尖我是這樣做的:
Is it possible? Using the nibs I did it like this:
ResultsController *rc = [[ResultsController alloc] initWithNibName:@"ResultsController"
bundle:nil];
[self.navigationController presentModalViewController:rc animated:YES];
[rc release];
現在我真的沒有 nib 文件,我該怎么做呢?
Right now I don't really have a nib files, so how do I do it?
推薦答案
看看 UIStoryboard 類.有一個 instantiateViewControllerWithIdentifier 方法.因此,您需要在 Storyboard Editor 中為 ResultsController ViewController 設置 Identfier.
Take a look at the UIStoryboard class. There is a instantiateViewControllerWithIdentifier Method. So you need to set the Identfier within the Storyboard Editor for your ResultsController ViewController.
你可以這樣做
UIViewController *viewController =
[[UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:NULL] instantiateViewControllerWithIdentifier:@"ResultsController"];
[self presentModalViewController:viewController animated:NO];
這篇關于如何在情節提要中創建 UIViewController 布局,然后在代碼中使用它?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!