ViewController.swift
@IBOutlet weak var btn_stop: UIButton!
AppDelegate.swift
let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController") as! ViewController
viewController.btn_stop.hidden=false
Error - gives me Fatal error & app Crash
Access your ViewController via the rootViewController option:
let viewController = self.window!.rootViewController as! ViewController
viewController.btn_stop.hidden = false // Found nil error
But even in this case it will find nil. The viewController is instantiated but not loaded yet. You should probably unhide the button in the viewDidLoad function of the ViewController.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.