且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

提出在iOS7和iOS8中均可使用的半透明viewcontroller

更新时间:2023-02-03 09:42:43

您必须处理iOS 7和iOS8的两种配置。在这两种情况下,您都需要确保背景视图控制器不会从视图层次结构中删除。这可以用:

You have to handle two configurations for iOS 7 and iOS8. In both case you need to make sure that the background view controller is not taken off the view hierarchy. This can be accomplish with:


  1. 在iOS7上设置 modalPresentationStyle 呈现视图控制器的 UIModalPresentationCurrentContext 标记。您需要确定谁是呈现视图控制器:如果您有多个容器视图控制器,则不一定是 self.navigationController

  1. On iOS7 by setting the modalPresentationStyle flag to UIModalPresentationCurrentContext for the presenting view controller. You need to identify who is the presenting view controller: it is not necessarily self.navigationController if you have multiple container view controllers.

在iOS8上,将 modalPresentationStyle 标志设置为 UIModalPresentationOverCurrentContext ,用于呈现查看控制器。如果您使用的是故事板,请确保故事板segue的演示文稿样式设置为Default,并在 prepareForSegue 方法中将目标视图控制器的演示样式设置为 UIModalPresentationOverCurrentContext

On iOS8 by setting the modalPresentationStyle flag to UIModalPresentationOverCurrentContext for the presented view controller. If you are using storyboard make sure the presentation style is set to Default for the storyboard segue and within the prepareForSegue method set the presentation style to the destination view controller to UIModalPresentationOverCurrentContext.

现在回答您的推论:

1)你需要有代码来处理iOS7和iOS8上的两种情况:

1) You need to have code to handle both situation on iOS7 and iOS8:

定义一些宏来检查版本号应用程序正在运行。例如,以下内容将:

Define some macros to check the version number the application is running on. For example the following will do:

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

2)显然,如果您的代码需要在iOS7和iOS8上编译,那么您的团队需要更新到最新的版本nC of XCodeXCode 6.1截至目前。

2) Obviously if you have code that needs to be compiled on iOS7 and iOS8 so your team needs to update to the latest version of XCode" XCode 6.1 as of now.