openURL
has been deprecated in Swift3. Can anyone provide some examples of how the replacement openURL:options:completionHandler:
works when trying to open an url?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
All you need is:
Above answer is correct but if you want to check you
canOpenUrl
or not try like this.Note: If you do not want to handle completion you can also write like this.
No need to write
completionHandler
as it contains default valuenil
, check apple documentation for more detail.Swift 3 version
I'm using macOS Sierra (v10.12.1) Xcode v8.1 Swift 3.0.1 and here's what worked for me in ViewController.swift:
If you want to open inside the app itself instead of leaving the app you can import SafariServices and work it out.