I have a very simple UIWebView with content from my application bundle. I would like any links in the web view to open in Safari instead of in the web view. Is this possible?
Ios – UIWebView open links in Safari
iosmobile-safariuiwebview
Related Question
- Ios – How to link to apps on the app store
- Ios – How to sort an NSMutableArray with custom objects in it
- Ios – How to check for an active Internet connection on iOS or macOS
- Ios – How to make a UITextField move up when the keyboard is present – on starting to edit
- Ios – Passing data between view controllers
- Ios – Load resources from relative path using local html in uiwebview
- Ios – How to launch Safari and open URL from iOS app
- Javascript – Is Safari on iOS 6 caching $.ajax results
Best Solution
Add this to the UIWebView delegate:
(edited to check for navigation type. you could also pass through
file://
requests which would be relative links)Swift Version:
Swift 3 version:
Swift 4 version:
Update
As
openURL
has been deprecated in iOS 10: