Transition to a view controller with Swift WebKit

Transition under certain conditions (for example, when a button is pressed)

@IBAction func btnClick(_ sender: Any) {
    self.performSegue(withIdentifier: "Identify specified by segue", sender: nil)

Open the specified URL with WebKit

@IBOutlet weak var webPage: WKWebView!
    override func viewDidLoad() {

        let homeUrl=""
        openUrl(urlString: homeUrl)
        webPage.navigationDelegate = self
    //Open Web View with the URL specified by the string
        func openUrl(urlString: String) {
            let url = URL(string: urlString)
            let request = NSURLRequest(url: url!)
            webPage.load(request as URLRequest)

Back to previous page Button action

@IBAction func goBack(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)

WebKit full screen

Set the following two of Segue スクリーンショット 2020-10-04 22.47.56.png

In the case of iPhone X etc., if only the above is done, the time on the screen etc. will be left out, so this is also necessary スクリーンショット 2020-10-05 13.29.17.png

Get device orientation

The following settings are required to obtain the motion sensor of the device

    var rcvURL=""
    override func viewDidLoad() {
        webView.uiDelegate = self //I need this
        webView.navigationDelegate = self
        openUrl(urlString: rcvURL)

MediaPlaerPlayback error?

A white box of Media Player and a controller for video playback appear on the screen. Checking all the properties (?) Of the Web View solved this problem. Cause unknown. スクリーンショット 2020-10-05 16.29.03.png


Recommended Posts

Transition to a view controller with Swift WebKit
Convert a string to a character-by-character array with swift
Add a local Swift Package to your project with Swift PM
Port C code with a lot of typecasts to Swift
[Swift] How to send a notification
Sample code to unit test a Spring Boot controller with MockMvc
Fall when animating a View containing an Android Recycler View with Transition
Customize View with View Modifier in Swift UI
How to return a value from Model to Controller using the [Swift5] protocol
[Swift] Converts a UInt64 type integer to [UInt8]
Manage View status with enum in Swift
[iOS] I tried to make a processing application like Instagram with Swift
[Swift] How to use Tab Bar Controller
[Swift] Easy to implement modal with PanModal
Transition from Struts2 to Spring MVC (Controller)
[Swift5] How to create a splash screen
[SpringBoot] How to write a controller test
It's a pain to deal with old dates
[Rails] rails new to create a database with PostgreSQL
Rip a CD to MP3 with Ubuntu 18.04 LTS
Try drawing a cube with View and Layer
Incorporate View created with Swift UI into ViewController
I tried to break a block with java (1)
Add packages to your project with Swift PM
How to implement UICollectionView in Swift with code only
Minecraft BE Tap with a wooden sword to jump
How to make a factory with a model with polymorphic association
Submit a job to AWS Batch with Java (Eclipse)
Considering a property editor to use with SpringToolSuite (STS)
How to delete a new_record object built with Rails
How to manually generate a JWT with Rails Knock
I want to monitor a specific file with WatchService
A story about trying to get along with Mockito
[How to insert a video in haml with Rails]
Refusing to install package with name "webpack" under a package
I want to transition screens with kotlin and java!
A story about reducing memory consumption to 1/100 with find_in_batches
[Rails] How to edit and customize devise view and controller
[Rails] How to load JavaScript in a specific view
How to get started with creating a Rails app
[Java] How to start a new line with StringBuilder
[Rails] What to do when the view collapses when a message is displayed with the errors method