SFSafariViewController

SFSafariViewController

本文介绍了SFSafariViewController 在 UINavigationController 中使用 modalPresentationStyle = .FormSheet 推送时显示不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的设置表视图,它是 UINavigationController 的第一个视图.

I have a simple Settings table view that is the first view of a UINavigationController.

我使用 .FormSheet modalPresentationStyle 呈现设置 UINavigationController,这意味着在 iPhone 上它占据全屏,而在 iPad 上,它以模态方式居中显示.

I present the Settings UINavigationController with the .FormSheet modalPresentationStyle, which means on an iPhone it takes up the full screen, while on an iPad, it displays centered modally.

现在我希望设置表中的某一行将 SFSafariViewController 推送到导航堆栈上.

Now I want want one of the rows in the Settings table to push a SFSafariViewController onto the navigation stack.

这在 iPhone 上运行良好,但在 iPad 上则不行.iPad 截图:

This works fine on an iPhone, but on the iPad it does not. iPad screenshot:

请注意,SFSafariViewController 导航栏的一部分显示在导航栏下方(带有设置后退按钮).请参阅图像中的红色矩形.

Note that the part of the SFSafariViewController navigation bar shows underneath the navigation bar (with the Settings back button). See red rectangle in image.

let urlText = "http://www.apple.com"       
let url = NSURL(string: urlText)!     
let safariViewController = SFSafariViewController(URL: url)
self.navigationController?.pushViewController(safariViewController, animated: true)

在 iPhone 上,您根本看不到 SFSafariViewController 导航栏 - 这非常适合我的用例.

On the iPhone, you don't see the SFSafariViewController navigation bar at all - which is perfect for my use case.

有什么神奇的设置可以让它正常工作吗?

Any magic setting to make this work correctly?

推荐答案

SFSafariViewController适用于iOS9.0及以上版本的apple os.根据您的问题,您遇到了一些问题,使用 SFSafariViewController 视图在导航栏中显示一些差距.因为

SFSafariViewController is available to iOS9.0 or above version of apple os.According to your problem you have facing some problem show some gap in you navigation bar with SFSafariViewController view.because

SFSafariViewController 嵌入了自己的导航栏、UISearchbar、UIBarButton.当您从 ViewController 上推送 SFSafariViewController 时,您的应用导航栏会显示在 SFSafariViewController 导航栏上.

SFSafariViewController is embed own navigation bar, UISearchbar, UIBarButton.when you push SFSafariViewController from over ViewController then you app navigation bar show over the SFSafariViewController navigation bar.

这篇关于SFSafariViewController 在 UINavigationController 中使用 modalPresentationStyle = .FormSheet 推送时显示不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 09:53