检测应用程序是否在 iOS 9 中的 Slide Over 或 Split View 模式下运行 [英] Detect if app is running in Slide Over or Split View mode in iOS 9

查看:23
本文介绍了检测应用程序是否在 iOS 9 中的 Slide Over 或 Split View 模式下运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iOS 9 中,是否可以检测应用何时在 iOS 9 的侧拉或分屏模式下运行?

In iOS 9, is it possible to detect when an app is running in iOS 9's Slide Over or Split View mode?

我尝试通读 Apple 的文档iOS 9 多任务处理,但对此没有任何运气......

I've tried reading through Apple's documentation on iOS 9 multitasking, but haven't had any luck with this…

我之所以这么问,是因为我的应用中可能有一个功能,当应用在侧拉中打开时,我想禁用该功能.

I ask because I might have a feature in my app that I'd like to disable when the app is opened in a Slide Over.

推荐答案

只需检查您的窗口是否占满整个屏幕:

Just check if your window occupies the whole screen:

BOOL isRunningInFullScreen = CGRectEqualToRect([UIApplication sharedApplication].delegate.window.frame, [UIApplication sharedApplication].delegate.window.screen.bounds);

如果这是错误的,那么您是在拆分视图或幻灯片中运行.

If this is false, then you're running in a split view or a slide over.

这里是剪下的代码,无论旋转如何,它都会自动保持这个标志

Here is the code snipped which will automatically maintain this flag irrespective of rotation

-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
{
 // simply create a property of 'BOOL' type
 isRunningInFullScreen = CGRectEqualToRect([UIApplication sharedApplication].delegate.window.frame, [UIApplication sharedApplication].delegate.window.screen.bounds);
}

这篇关于检测应用程序是否在 iOS 9 中的 Slide Over 或 Split View 模式下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆