0

我是 Xcode 的新手并下载了最新的 9.2 版本,我试图在按钮中插入指向 Web 的链接但无法正常工作。这是代码。 链接不起作用

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


    @IBAction func button(_ sender: Any) {



    if let url = URL(string: "https://www.youtube.com/watch?v=UPfA3mUfvGA&t=90s") {
        UIApplication.shared.canOpenURL(url)

        UIApplication.shared.open(url, options: [:], completionHandler:nil)

    }

}

}

当您按下 Guorlin Premium 按钮时,它会将您带到一个网站

现在,当我按下 Guorlin Premium 按钮不起作用时,它不会将我带到网站。

4

1 回答 1

0

只需按下option+shift+command+k并按下Ok以清理文件夹并尝试在真实设备而不是模拟器上运行它。

它绝对有效,我遇到了类似代码的类似问题,它对我有用。无需更改代码。

于 2018-10-12T04:41:23.923 回答