[IOS] using Xib as the application portal with code preface
When developing an iOS app, use storyboard to quickly and intuitively build a user interface. However, in the case of multi-person team development, because storyboard is a single file, it is easy to cause problems such as checkout, check-in, file lock, file merge conflict and so on. At this point, developers can choose to use Xib as the user interface of the development unit, the user interface into separate xib files, dispersed team members simultaneously edit the same file risk.
In Xcode, the default is to use storyboard as the application portal, which requires some extra steps to make the application entry more xib. This article explains how to write code to use Xib as an entry point for your application in the iOS app development process, leaving a record for yourself and hoping to help developers in need.
Operation 1. Create a single View application
Use Xcode to create a new project and select the project type of single View application.
2. Removal of Storyboard
Remove storyboard and related files.
3. Establish Viewcontroller
Establish the Mainviewcontroller as the entrance. (Remember to tick also create XIB file)
4. Clear Main Interface
Clears the application's entry setting parameters main Interface
5. Modify Appdelegate
Finally, add the following program code in Appdelegate to start the Mainviewcontroller.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.window = UIWindow(frame:UIScreen.mainScreen().bounds) self.window!.rootViewController = MainViewController(nibName: "MainViewController", bundle: nil) self.window!.makeKeyAndVisible() return true}
6. Implementation results
Compile and execute the sample project, you can see the iOS app, the correct use of Xib as the application portal.
Reference data
[IOS] using Xib as the application portal with Code