【发布时间】:2016-05-18 03:12:58
【问题描述】:
[编辑] 我重新启动了 iPad,它解决了这个问题。我把它留在这里是因为堆栈溢出不鼓励删除问题
我在iPad Air 2上发生了一件奇怪的事情。使用https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/WindowAndScreenGuide/UsingExternalDisplay/UsingExternalDisplay.html中提到的方法
我为通过 AirPlay 连接的辅助显示器创建了一个新的 UIWindow 对象。
- (void)checkForExistingScreenAndInitializeIfPresent {
if ([[UIScreen screens] count] > 1)
{
// Get the screen object that represents the external display.
UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
// Get the screen's bounds so that you can create a window of the correct size.
CGRect screenBounds = secondScreen.bounds;
self.secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
self.secondWindow.screen = secondScreen;
NSLog(@"Show external window");
// Set up initial content to display...
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Test" bundle:[NSBundle mainBundle]];
UIViewController *controller = [storyboard instantiateInitialViewController];
self.secondWindow.rootViewController = controller;
// Show the window.
self.secondWindow.hidden = NO;
}
}
当我在 iPhone 5s 上运行此代码时,该代码运行良好并且辅助窗口已初始化。但是,当我在 iPad Air 2 上从 Xcode 运行此代码时,我只看到黑屏。如果应用程序不是通过 Xcode 运行,应用程序会在 iPad 上启动,但在 AirPlay 显示屏上它只显示主屏幕,并突出显示应用程序图标。音频仍通过 AirPlay 路由。
任何帮助将不胜感激。
【问题讨论】:
-
这里有一个疯狂的猜测,但情节提要中是否有您尝试加载的“仅限 iPhone”的内容?这可以解释为什么它不显示在 iPad 上。
-
@Ermiar 你不会相信的。在数小时无法弄清楚之后,我重新启动了 iPad。奇迹般地,它奏效了!
-
哈哈好吧!在这种情况下,我不知道您是需要自己回答问题还是直接关闭它。无论如何,很高兴你找到了解决方案。
-
@Ermiar 我试图删除它,但我似乎找不到选项
-
你的帖子下其他人旁边没有“删除”按钮吗?
标签: ios iphone ipad airplay mirroring