I have a WKWebview
that is if course hooked up to the file through storyboard. You can see it is hooked in this picture:
As you see both in storyboard and in the UIViewController
file, the webView
is hooked.
I get a nil from the webView
the first time I call it in the viewDidLoad
on line 36.
This is the error:
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
How can I get Xcode to recognize there is a web view??
EDIT I load the VC like this:
let vc = joinFromInAppViewController()
vc.purchaseDate = purchaseDate
vc.purchaseEndDate = purchaseEndDate
vc.membershipPurchased = membershipPurchased
self.present(vc, animated: true, completion: nil)
The ViewController where the webView is in:
import UIKit
import WebKit
import RevealingSplashView
import SwiftEntryKit
class joinFromInAppViewController: UIViewController, WKNavigationDelegate {
@IBOutlet weak var webView: WKWebView!
var purchaseDate: Int = 0
var purchaseEndDate: Int = 0
var membershipPurchased: String = ""
let revealingSplash = RevealingSplashView(iconImage: #imageLiteral(resourceName: "RevealingSplashIconImage"), iconInitialSize: CGSize(width: 125, height: 125), backgroundColor: UIColor(red: 225/255, green: 32/255, blue: 62/255, alpha: 1.0))
var attributesShow = EKAttributes.bottomFloat
let defaults = UserDefaults.standard
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(revealingSplash)
revealingSplash.animationType = SplashAnimationType.heartBeat
let myURL = URL(string: "https://www.google.com")
let myRequest = URLRequest(url: myURL!)
webView.navigationDelegate = self
webView.load(myRequest)
//revealingSplash.startAnimation()
}
}
CodePudding user response:
Set an id to the vc inside storyboard and load it like this
let vc = storyboard!.instantiateViewController(withIdentifier: "Id") as! IoinFromInAppViewController