简体   繁体   English

有没有办法在 Xcode 11 中找到所有模态呈现的视图控制器?

[英]Is there a way to find all modally presented view controllers in Xcode 11?

I'm updating an app to work with Xcode 11 and iOS 13. It's a big app, and there are a lot of views that are presented modally.我正在更新一个应用程序以使用 Xcode 11 和 iOS 13。这是一个大应用程序,并且有很多以模态方式呈现的视图。

The problem is that with Xcode 11, modal views are by presented as sheet views by default.问题是在 Xcode 11 中,模态视图默认显示为工作表视图。 That means that my users can just dismiss them if they want.这意味着我的用户可以根据需要解雇他们。 I don't want that.我不想要那个。

I've searched the Xcode project for:我在 Xcode 项目中搜索:

self.present(

And to each of the view controllers that have been presented in code, I've added:对于代码中出现的每个视图控制器,我添加了:

modalPresentationStyle = .fullScreen

But of course, this only fixes the views that have been presented from code.但是,当然,这只修复了从代码中呈现的视图。 I have a lot of views that have been presented from storyboards.我有很多从情节提要中提出的观点。

Now, I am trying to find if there is a way to search storyboards for all views that have been presented modally.现在,我正在尝试查找是否有一种方法可以在情节提要中搜索以模态方式呈现的所有视图。

You can open your storyboards as source code individually in Xcode, or open them all in a text editor like Sublime or Atom.您可以在 Xcode 中将您的故事板作为源代码单独打开,或者在 Sublime 或 Atom 等文本编辑器中将它们全部打开。 Then you can search for segues that have kind="modal" .然后,您可以搜索具有kind="modal"的 segue。

Segues will default to "Same As Destination" for the "Presentation" style so it's often easier to just explicitly set the presentation style of the view controller being presented, which you can specify in the storyboard as well. Segues 将默认为“Presentation”样式的“Same As Destination”,因此通常更容易明确地设置正在呈现的视图 controller 的呈现样式,您也可以在 storyboard 中指定它。 Change "Presentation" on the view controller from "Automatic" to "Full Screen" (or whatever you want).将视图 controller 上的“演示文稿”从“自动”更改为“全屏”(或任何您想要的)。 That way for any view controllers where you don't want them to be presented as popovers, you can ensure they will always be full screen.这样,对于您不希望它们显示为弹出框的任何视图控制器,您可以确保它们始终是全屏的。

Xcode 与目标 segue 演示相同

Xcode 视图控制器演示样式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM