84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
有一个标签页继承自UIViewController,这个视图控制器的界面使用storyboard实现的,如何在加载视图控制器的时候打开的是已经设计好的相应storyboard的UI界面?
如图在这一页加载那个storyboard
小伙看你根骨奇佳,潜力无限,来学PHP伐。
First you need to set the Storyboard ID corresponding to this vc in the storyboard, as shown in the picture
Then you can load the object directly through this id in the code
XXXViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"xx_id"];
It can be used if self.storyboard is nil
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"XX_storyboard_name" bundle:[NSBundle mainBundle]]; XXXViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"xx_id"];
Refer to this article: http://lvwenhan.com/ios/452.html
The viewcontroller using StoryBoard must be initialized from the storyboard, just use this code:
let vc = UIStoryboard(name: "Second", bundle: nil).instantiateInitialViewController() as! UIViewController self.navigationController?.pushViewController(vc, animated: true)
First give it an ID in the storyboard, such as MainViewController.
MainViewController
Then when initializing VC:
UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil]; MainViewController *mainController = [mainStoryboard instantiateViewControllerWithIdentifier:@"MainViewController"];
This is OC, just translate it into swift.
First you need to set the Storyboard ID corresponding to this vc in the storyboard, as shown in the picture
Then you can load the object directly through this id in the code
It can be used if
self.storyboard is nil
The viewcontroller using StoryBoard must be initialized from the storyboard, just use this code:
First give it an ID in the storyboard, such as
MainViewController
.Then when initializing VC:
This is OC, just translate it into swift.