Differences between nib, xib, and storyboard in iOS and the loading process of storyboard, nibxib
First, let's talk about nib. nib is a product earlier than version 3.0. On the terminal, we can see that NIB is actually a folder with executable binary files;
What is the difference between xib and storyboard?
Differences:
1> whether it is nib or xib, it will eventually be converted into executable nib files before executing the UIViewController lifecycle function loadView.
2> storyboard is a description file of multiple xib file sets. An xib file corresponds to one view controller and multiple views.
In toryboard, only one primary storyboard file is required for a project.
Similarities:
1> it is an xml-based description file that enables visual programming.
// Certificate //---------------------------------------------------------------------------------------------------------------------------------------------------------------//
Main. storyboard file. In this case, how is storybord loaded?
When creating storyboard apps, several default files are automatically generated. AppDelegate. h is one of them. The diagram is as follows:
Import <UIKit/UIKit. h>
@ Interface AppDelegate: UIResponder <UIApplicationDelegate>
@ Property (strong, nonatomic) UIWindow * window;
@ End
We need to pay special attention to these default files to find out the ins and outs.
AppDelegate inherits from UIResponder and has a UIWindow property. The declaration method is concise.
Open the default generated AppDelegate. m file, and you will be surprised that the code displayed by AppDelegate. m is almost empty. All methods are empty. Even if application: didfinishlaunchingwitexceptions:, only YES is returned, and no other code is available.
That is to say, neither AppDelegate. h nor AppDelegate. m has seen any xuanjicang. It looks like a huge storyboard. How did you play it?
The saying goes well. It is not enough to view AppDelegate. h/m alone. There are three other good guys in storybord.
When storyboard apps is started, how does it know where to load the main. storyboard file? The secret is on info. plist.
You will see that the key value of UIMainStoryboardFile or "Main storyboard file base name" is set to Main.
When the app is started, UIApplicaiton automatically loads the main. storyboard file. At the same time, the first view controller (view controller) on the main. storyboard is automatically loaded, and the View corresponding to the view controller is loaded into the UIWindow object.
You may have noticed that this was done when the app was started, but we haven't compiled a line of code yet. The biggest significance of storyboard technology is to greatly reduce the amount of Code related to the UI.
Storyboard helper: Deployment Info settings. As follows:
Storyboard helper: main. m file, the Code is as follows:
#import <UIKit/UIKit.h>#import "AppDelegate.h"int main(int argc, char *argv[]){ @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }}
In main. m, although there are not many statements, this statement directly determines the life cycle of the app. This line of code is used to pass the app delegate class to UIApplicationMain.
The entry for starting and running the entire App is in UIApplicationMain.
The above describes the loading process of sotroyboard. Regardless of nib or storyboard, the loading principle of its UIMainWindow is the same.
However, nib school needs to write more code manually. After understanding these principles, even if you create a project based on Xcode5, you can ignore the main. storyboard,
You can freely move between your own nib. The so-called "My nib, I have the final say, create as much nib as you want ". This is the Feel. Write 1000 lines of code a day, so you can easily do it.