Ololo Ololo - 1 year ago 78
iOS Question

Open url and stay in app

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?

Answer Source

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.