[IOS] using Xib as the application portal with Code

Source: Internet
Author: User

[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
    • [Swift] iOS Development Note (ii): Using xib files in Xcode6 iOS projects-Ban Hao Technical Research website

    • How to not use Storyboard-rex Chen in Swift Project

[IOS] using Xib as the application portal with Code

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.