Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In iOS 9, why is SFSafariViewController is being pushed instead of presented modally?

I'm presenting a SFSafariViewController by calling presentViewController:animated:completion: on a UIViewController instance.

The result is that it gets pushed on (slides in from the right), as if I called pushViewController:animated: on a UINavigationController instance. I've verified that this is all happening on the main queue. And the presenting view controller is not a modal itself (which shouldn't matter anyways, but just in case, we can rule that out).

If I substitute the SFSafariViewController with a UIViewController, it works as expected, it presents modally.

weakSelf.oAuthViewController = [[SFSafariViewController alloc] initWithURL:url]; [viewController presentViewController:weakSelf.oAuthViewController animated:YES completion:nil]; 

Any idea why or how to work around this?

like image 884
abc123 Avatar asked Feb 25 '16 13:02

abc123


People also ask

How do I present SFSafariViewController?

A common approach to place the SFSafariViewController inside SwiftUI is to create a simple view representing a SFSafariViewController , then present it with a sheet(isPresented:onDismiss:content:) modifier or a NavigationLink button (See ContentView. swift in the demo project).

Does SFSafariViewController share cookies?

SFSafariViewController no longer shares cookies with the standalone Safari browser. Thus, a website can no longer determine that the user on SFSafariViewController is the same user on Safari, even though the view controller and the browser are open on the same device.

What is Safari view controller?

Safari View Controller's job is to make it fast, easy and enjoyable for users to tap on a link within your app, view a web page and press done to go right back to your app. Safari View Controller eliminates distractions. The URL field that you see up there, it's read only.


1 Answers

Here's a simple way to obtain a vertical modal presentation of a SFSafariViewController:

let safari = SFSafariViewController(URL: url) safari.modalPresentationStyle = .overFullScreen presentViewController(safari, animated: true, completion: nil) 
like image 72
jamesk Avatar answered Sep 22 '22 03:09

jamesk