如何在iOS中切换回镜像?

时间:2012-12-10 15:05:46

标签: ios mirroring

我在关于Presenting Content on an External Display的Apple文档中阅读了关于在外部屏幕上显示另一个视图(这会禁用镜像)的信息。但似乎当第二个窗口设置为屏幕时,无法将屏幕恢复为镜像第一个窗口。

在UIScreen对象上有一个名为mirroredScreen的属性,如果设备能够镜像并且镜像仍处于活动状态,则该属性被描述为包含镜像屏幕。当另一个窗口与UIScreen关联时,它变为零。但它是一个只读属性,没有其他方法可以将其重新设置为镜像:(

1 个答案:

答案 0 :(得分:1)

我完全一样,导致黑屏无法重置。对我来说,以下代码的组合起到了作用。首先,重置第二个窗口,第二个,重新分配主屏幕,使其再次触摸。

// Reset the second window
self.secondWindow.frame = CGRectZero;
self.secondWindow.screen = nil;
self.secondWindow = nil;

// Reassign your main screen to make it work with touches again
UIWindow *mainScreen = [[[UIApplication sharedApplication] windows] firstObject];
[mainScreen makeKeyAndVisible];