[SWIFT] How to develop separately into Xib files without using Storyboard

This is my first post! This is Lee. I will post it like a memo so that I will not forget what I learned in my studies.

It seems that Storyboard is rarely used in practice. I will introduce how to develop by dividing into Xib files without using Storyboard.

First, let's delete the view controller and storyboard after creating the project! !! スクリーンショット 2020-11-11 13.24.40.png After deleting, add the file. Be sure to check Also create XIB file before adding a file with cocoa TouchClass. This time, name it sampleViewController. スクリーンショット 2020-11-11 13.25.21.png After creating the file, set it in Info.plist. 4th from the bottom of this screen [Delete the Main storyboard file base name with a minus. スクリーンショット 2020-11-11 13.28.50.png Next, press the arrow of Application Scene Manifest and it will look like the image. The Storyboard Name of [Item 0] is also deleted with a minus. スクリーンショット 2020-11-11 13.29.16.png

This is the end of the setting. From here, it will be created automatically after creating the project We'll write the code in the SceneDelegate.swift file! I don't know what the code here is, so let's remember it like a spell lol

SceneDelegate.swift


import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?


    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let scene = (scene as? UIWindowScene) else { return }
        window = UIWindow(windowScene: scene)
        window?.makeKeyAndVisible()
        
        let sampleVC = sampleViewController()
        let rootVC = UINavigationController(rootViewController: sampleVC)
                window?.rootViewController = rootVC
    }

This will also add a navigation bar! !! In this way, a blank screen is displayed first without any error. Simulator Screen Shot - iPod touch (7th generation) - 2020-11-11 at 14.00.41.png

Since the storyboard is gone, we will continue to use XIB for the screen UI. That's how to develop Xib files separately without using Storyboard! !!

Recommended Posts

How to develop separately into Xib files without using Storyboard
How to develop OpenSPIFe
How to start tomcat local server without using eclipse
How to use Play Framework without using typesafe activator
The first step to using Xib instead of StoryBoard
How to load UI created by Xib file into View
How to output array values without using a for statement
How to install JDK 8 on Windows without using the installer
How to join a table without using DBFlute and sql
How to play MIDI files using the Java Sound API
How to rollback migration files
How to authorize using graphql-ruby
How to control transactions in Spring Boot without using @Transactional
How to disassemble Java class files
How to decompile java class files
How to build CloudStack using Docker
[Swift] How to set an image in the background without using UIImageView.
How to sort a List using Comparator
How to share files with Docker Toolbox
How to use binding.pry for view files
[Rails] How to upload images using Carrierwave
[Java] How to calculate age using LocalDate
[Java] How to output and write files!
[Swift5] How to implement animation using "lottie-ios"
How to implement image posting using rails
How to make asynchronous pagenations using Kaminari
[Rails] How to translate devise into Japanese
[Rails] How to handle data using enum
How to insert icons using Font awesome
How to play MIDI files using the Java Sound API (specify the MIDI device to use)