Creation of Uiviewcontroller in iOS

Source: Internet
Author: User

In an iOS program, an app defaults to only one uiwindow. UIWindow is a special UIView control and the first UIView object created after the program starts, in order to understand the relationship between UIWindow and Uiviewcontroller, and the creation of Uiviewcontroller, Start with a new Emptyapplication project.

Empty project, the default directory structure only Appdelegate class, this class is the delegate of the Application object, will be in the different life cycle of the program callback different methods (about the application life cycle of the topic, and so I learned good in hooves ... The code in Didfinishlaunchingwithoptions is as follows

?
1 2 3 4 5 self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];      //Override point for customization after application launch.      self.window.backgroundcolor = [Uicolor whitecolor];      [self.window makekeyandvisible];      return yes;

You can see that the program is started, the Appdelegate object creates a UIWindow object, sets the background color of the window to white, and then makes it visible through makekeyandvisible and becomes the main window, and runs directly to see a white area unfold in front of you. All UI elements on the interface, if you want to show it, must rely on the UIWindow object, without specifying UIWindow's UIView, it will automatically generate a UIView object. Creating Uiviewcontroller is roughly custom created directly, created through storyboard, and created using xib files.

(not to be continued ...) )

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.