我尝试使用以下代码来做到这一点。然而,它不起作用。
警告:尝试呈现不在窗口层次结构中的 View !
有没有办法在不点击按钮的情况下调用其他 View Controller ?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let configuration = WKWebViewConfiguration()
let controller = WKUserContentController()
controller.addScriptMessageHandler(self, name: "JSListener")
configuration.userContentController = controller
let webview = WKWebView(frame: self.view.frame, configuration: configuration)
let url = NSBundle.mainBundle().URLForResource("index1", withExtension: "html")
let request = NSURLRequest(URL: url!)
self.view = webview
webview.loadRequest(request)
let secondViewController:UIViewController = OurTableViewController()
self.presentViewController(secondViewController, animated: true, completion: nil)
}
最佳答案
尝试移动
let secondViewController:UIViewController = OurTableViewController()
self.presentViewController(secondViewController, animated: true, completion: nil)
像这样查看DidAppear
override func viewDidAppear(animated: Bool) {
let secondViewController:UIViewController = OurTableViewController()
self.presentViewController(secondViewController, animated: true, completion: nil)
}
关于ios - ( swift )初始 View Controller 调用 TableView Controller 而不点击任何按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37403676/