Reputation: 15
I want to open any url in app and stay in app like this done in Skype. It opens safari page with "done" button in top left corner but you still in Skype.Can anyone help me?
Upvotes: 1
Views: 2417
Reputation: 69459
The example your are showing is using the SFSafariViewController
. This will show Safari in your app, this class is available in iOS 9 or newer.
You could use a check like this if you plan to support versions lower then iOS 9:
if ([SFSafariViewController class]) {
SFSafariViewController *viewController = [[SFSafariViewController alloc] initWithURL:url];
[self presentViewController:viewController animated:YES completion:nil];
} else {
WebViewController *viewController = [[WebViewController alloc] init];
viewController.url = url;
[self presentNavigationControllerWithViewController:viewController animated:YES completion:nil];
}
Here WebViewController
is just a view controller with a UIWebView
that will load the page. You can create your own tool bar like SFSafariViewController
to go back/forward or open in Safari.
Upvotes: 5
Reputation: 1167
If you want to open any web page within your app,
Create UIViewController
subclass and follow the steps
To open page from other ViewController:
WebViewController *webVC=[self.storyboard instantiateViewControllerWithIdentifier:@"WebViewControllerIdentifier"];
webVC.url=@"http://example.com";
[self presentViewController:webVC animated:YES completion:nil];
Upvotes: 1
Reputation: 21808
You can use simply SFSafariViewController
. This is the simplest way to achieve what you want. I believe Skype uses exactly that. You can put it inside UINavigationController
or whatever another container view controller
Upvotes: 0