The first step to using Xib instead of StoryBoard

environment

Xcode12.3

goal

Remove StoryBoard and launch it from Xib.

Create a project

スクリーンショット 2021-01-01 14.06.59.png

Removed ViewController and StoryBoard

Select ViewController.Swift and Main.storyBoard> Right click> Delete> Move to Trash

Info.plist settings

(1) Main storyboard file base name> Delete

(2) Application Scene Manifest> Scene Configuration> Application Session Role> Item 0 (Default Configuration)> Storyboard Name> Delete If you do not delete (2) as well, an error will occur.

Create ViewController and Xib files

New File> Cocoa Touch Class> Subclass of: UIViewContoroller> Also create Check XIB file> Next> Create

スクリーンショット 2021-01-01 14.40.28.png I was able to create two files.

スクリーンショット 2021-01-01 14.42.53.png This time, set the background to blue so that it is easy to understand when starting up.

Set SceneDelegate.swift

Set the screen displayed at startup with func scene (_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) to ViewContoroller that supports Xib files.

SceneDelegate.swift


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let _ = (scene as? UIWindowScene) else { return }
        //Postscript from here
        let window = UIWindow(windowScene: scene as! UIWindowScene)
        self.window = window
        window.makeKeyAndVisible()
        let xibViewController = XibViewController()
        window.rootViewController = xibViewController
        
    }

Start the simulator

スクリーンショット 2021-01-01 15.13.28.png The Xib with the blue background that I set earlier has started up firmly.

reference

Implement screen with xib instead of StoryBoard [Swift] Launch from Xib instead of StoryBoard on iOS 13

Recommended Posts

The first step to using Xib instead of StoryBoard
Try using || instead of the ternary operator
[Java Servlet] The road of Senri is also one step to the first
How to develop separately into Xib files without using Storyboard
The story of pushing Java to Heroku using the BitBucket pipeline
[Apache Tomcat] The story of using Apache OpenWebBeans to enable CDI
How to get the contents of Map using for statement Memorandum
I want to display the number of orders for today using datetime.
[Java Servlet] The road of Senri is also the fifth step from the first step
[Java Servlet] The road of Senri is also the third step from the first step
[Java] How to get to the front of a specific string using the String class
[Java Servlet] The road of Senri is also the fourth step from the first step
[Ruby On Rails] How to search the contents of params using include?
The secret to the success of IntelliJ IDEA
Automatically adjust the height of Xib files
Introduction to java for the first time # 2
Test the integrity of the aggregation using ArchUnit ②
How to determine the number of parallels
How to sort the List of SelectItem
Output of the book "Introduction to Java"
Test the integrity of the aggregation using ArchUnit ③
The story of intentionally using try catch for the first time in my life
[Promotion of Ruby comprehension (1)] When switching from Java to Ruby, first understand the difference.
Volume of optimizing Hyper-v to eliminate the tightness of disk capacity (engineer using Docker)
Up to the point of launching a Docker container built using RedHat Quarkus
[Java] How to easily get the longest character string of ArrayList using stream
The first year of working people summarized how to take the Java Bronze exam
Pay attention to the boundary check of the input value when using the float type
Send a notification to slack with the free version of sentry (using lambda)
How to find the cause of the Ruby error
I tried using Docker for the first time
[Rails] Button to return to the top of the page
Add empty data to the top of the list
Customize how to divide the contents of Recyclerview
[Delete the first letter of the character string] Ruby
Make a margin to the left of the TextField
The story of learning Java in the first programming
The story of introducing Ajax communication to ruby
The story of raising Spring Boot 1.5 series to 2.1 series
I want to var_dump the contents of the intent
How to implement the breadcrumb function using gretel
How to get today's day of the week
Change the timezone of the https-portal container to JST
Output of how to use the slice method
[Ruby] Code to display the day of the week
The story of adding the latest Node.js to DockerFile
How to display the result of form input
Push the image to docker hub using Jib
[Java] How to get the authority of the folder
I tried using the profiler of IntelliJ IDEA
First touch of the Files class (or Java 8)
Java Welcome to the Swamp of 2D Arrays
[Final version] Check the operation of the Japanese calendar using ICU to support the new era.
How to get the class name of the argument of LoggerFactory.getLogger when using SLF4J in Java
I tried to investigate the mechanism of Emscripten by using it with the Sudoku solver
[Rails] How to display the weather forecast of the registered address in Japanese using OpenWeatherMap