简体   繁体   English

如何在iOS中切换回镜像?

[英]How can I switch back to mirrorring in iOS?

I read about displaying another view on an external screen (and that this disables mirroring) in Apple's documentation on Presenting Content on an External Display . 我在Apple的“在外部显示器显示内容”文档中阅读了有关在外部屏幕上显示另一个视图(并且这将禁用镜像)的信息。 But it seems that when a second window is set to be for a screen there's no way to get the screen back to mirroring the first one. 但是似乎将第二个窗口设置为一个屏幕时,无法将屏幕恢复为第一个窗口的镜像。

There is a property called mirroredScreen on the UIScreen object that is described as containing the mirrored screen if the device is able to mirror and mirroring is still active. 如果设备能够进行镜像并且镜像仍然处于活动状态,则UIScreen对象上有一个称为mirroredScreen的属性,该属性被描述为包含镜像屏幕。 It goes nil when another window is associated with the UIScreen. 当另一个窗口与UIScreen关联时,它变为nil。 But it's a read-only property and there's no other way to set it back up for mirroring :( 但这是一个只读属性,没有其他方法可以将其设置为进行镜像:(

I had exactly the same, resulting in a black screen without resetting back. 我完全一样,导致黑屏而没有复位。 For me the combination of the following code did the trick. 对我来说,以下代码的组合可以解决问题。 First, reset the secondWindow, second, reassign your main screen to make it work with touches again. 首先,重置secondWindow,其次,重新分配主屏幕,使其再次与触摸配合使用。

// 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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM