I am currently opening the link in my app in a WebView
, but I'm looking for an option to open the link in Safari instead.
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- Using if let syntax in switch statement
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Safari blocks play() on video despite being called
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
UPDATED for Swift 4: (credit to Marco Weber)
OR go with more of swift style using
guard
:Swift 3:
You can check NSURL as optional implicitly by:
Swift 3 & IOS 10.2
It's not "baked in to Swift", but you can use standard
UIKit
methods to do it. Take a look atUIApplication
'sopenUrl()
.Swift 4
Swift 3
Swift 2.2
In Swift 1.2:
since iOS 10 you should use:
New with iOS 9 and higher you can present the user with a
SFSafariViewController
(see documentation here). Basically you get all the benefits of sending the user to Safari without making them leave your app. To use the new SFSafariViewController just:and somewhere in an event handler present the user with the safari view controller like this:
The safari view will look something like this: