Controller controllers in the same Code load storyboard

Source: Internet
Author: User


First, the view
test.storyboard Name of the controller that was created by the code load storyboard file is the file name, and the following storyboard is the filename extension

1. This method is called after the application starts, and is no longer called after it is started!
If the application is killed by the operating system due to memory and other reasons, clicking the icon again will call this method!
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions
{
Instantiate UIWindow, Special UIView
Self.window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];
Set the background color of a window
Self.window.backgroundColor = [Uicolor Whitecolor]; 1. Load the storyboard file first (test is the file name of storyboard)
Uistoryboard*storyboard = [Uistoryboard storyboardwithname:@ "Test" bundle:nil]; Bundle Pass Nil The default is the main bundle
2, then initialize the Controller method in the storyboard 1, initialize the "Initial controller" (storyboard the arrow refers to the Controller) Mjviewcontroller *MJ = [Storyboard Instantiateinitialviewcontroller];
Method 2,Initialize the corresponding controller via an identity Mjviewcontroller *MJ = [Storyboard instantiateviewcontrollerwithidentifier:@ "Pink"];
Adding identifiersTo add a view control to the root view of the Windows window
Self.window.rootViewController =; MJ

Turn the window into the main window and visible
[Self.window makekeyandvisible];

return YES;
} second, load the main storyboard file through the project SetupIt is better to click the arrow to select (manual input should be careful not to add a space) or it will not be read out

Controller controllers in the same Code load storyboard

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.