在iOS 9中检测应用程序是否在“幻灯片放映”或“拆分视图”模式下运行 [英] Detect if app is running in Slide Over or Split View mode in iOS 9
问题描述
在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多任务的一个href =https://developer.apple.com/library/prerelease/ios/documentation/WindowsViews/Conceptual/AdoptingMultitaskingOniPad/index.html>文档,但没有任何运气有这个...
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中检测应用程序是否在“幻灯片放映”或“拆分视图”模式下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!