iOS development from getting started to mastering--xib usage Introduction

Source: Internet
Author: User

Xib Usage Introduction:
First we delete something we don't need:

Then we create a new view controller

Red Arrow also create XIB file to tick on

At this time, we can see that there are three files created successfully, there is a rootcontroller.xib file, in this there is a phone-like view, we can drag on the right side of some controls on the top

The following starts this view code to write in Agent APPDELEGATE.M:
To introduce #import "RootController.h"

#import "AppDelegate.h"#import "RootController.h"@interfaceAppdelegate ()@end@implementationappdelegate-(BOOL)Application:(uiapplication *) applicationdidfinishlaunchingwithoptions:(Nsdictionary *) launchoptions {//Override Point forCustomization after application launch.//Creates a Window object self.window=[[uiwindow Alloc]initWithFrame: [UIScreen mainscreen].bounds];//Method One: Explicitly load the Xib file//Create a root View Controller object//Parameter one: Load xib resource file name when creating, load Xib as View Controller view//Parameter two: Refers to the main package, the location of Xib, Mainbundle is the main resource file package. If nil is passed, the function is automatically found in the Mainbundle//Rootcontroller * root = [[Rootcontroller alloc]Initwithnibname:@"Rootcontroller" Bundle: [NSBundle Mainbundle]];//Rootcontroller * root = [[Rootcontroller alloc]Initwithnibname:@"Rootcontroller" Bundle: nil];//Method Two: Implicitly loading the Xib file//If the system has xib name (Rootcontroller.xib) and the class name are the same (Rootcontroller),//iThe NIT function automatically loads the Rootcontroller.xib file Rootcontroller * root = [[Rootcontroller alloc]init]; Self.window. rootviewcontroller=root; [Self.windowMakekeyandvisible];returnYES;} - (void)applicationwillresignactive:(UIApplication *) Application {//Sent whenThe application isAbout-to-move from active-to-inactive state. This can occur forCertain types ofTemporary interruptions (such as an incoming phone callorSMS message)or  whenThe user quits the application andIt begins the transition to the background state.//Use Thismethod to pause ongoing tasks, disable timers, andThrottle down OpenGL ES frame rates. Games should use Thismethod to pause the game.} - (void)Applicationdidenterbackground:(UIApplication *) Application {//Use Thismethod to release shared resources, save user data, invalidate timers, andStore enough application state information to restore your applicationinch  CaseIt isTerminated later.//If your application supports background execution, ThisMethod isCalled instead of applicationwillterminate: whenThe user quits.} - (void)Applicationwillenterforeground:(UIApplication *) Application {//Called as part ofThe transition from the background to the inactive state; Here you can undo many ofThe changes made onEntering the background.} - (void)applicationdidbecomeactive:(UIApplication *) Application {//Restart any tasks were paused (or  notYet started) whileThe application was inactive. If the application was previouslyinchThe background, optionally refresh the user interface.} - (void)applicationwillterminate:(UIApplication *) Application {//Called whenThe application isAbout to terminate. Save dataifappropriate. See AlsoApplicationdidenterbackground:.}@end

iOS development from getting started to mastering--xib usage Introduction

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.