使用外部显示器显示独特内容后,如何在 iPad 应用程序上重新启用应用程序镜像?
在我的应用程序中,我创建一个辅助窗口并向其添加一个子视图,以便主屏幕(ipad)和外部显示屏显示不同的内容。
我的问题是,当我不再希望显示唯一内容后,如何重新启用默认应用程序镜像?我尝试仅释放我创建的窗口,并尝试设置屏幕mirroredScreen属性,但它是只读的。
以下是在外部显示器上添加独特内容的代码:
if ([[UIScreen screens] count] > 1) {
//allocate another window
UIScreen* secondScreen = [[UIScreen screens] objectAtIndex:1];
CGRect screenBounds = secondScreen.bounds;
secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
secondWindow.screen = secondScreen;
shareViewController.view.hidden = NO;
//add the shareViewController's view to the external display
shareViewController.view.frame = secondWindow.frame;
[secondWindow addSubview:shareViewController.view];
secondWindow.hidden = NO;
}
In my application, I create a secondary window and add a subview to it, so that the main screen(ipad) and the external display screen show different things.
My question is, after I no longer want unique content shown, how can I re-enable the default app mirroring? I tried just releasing the window I created, and also tried to set the screens mirroredScreen property, but it is readonly.
Here is the code for adding the unique content on external monitor:
if ([[UIScreen screens] count] > 1) {
//allocate another window
UIScreen* secondScreen = [[UIScreen screens] objectAtIndex:1];
CGRect screenBounds = secondScreen.bounds;
secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
secondWindow.screen = secondScreen;
shareViewController.view.hidden = NO;
//add the shareViewController's view to the external display
shareViewController.view.frame = secondWindow.frame;
[secondWindow addSubview:shareViewController.view];
secondWindow.hidden = NO;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说,简单地将第二个窗口设置为零是行不通的。
以下代码的组合就达到了目的。首先,重置第二个窗口,其次,重新分配主屏幕以使其再次支持触摸。
For me simply setting my second window to nil didn't work.
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.
只要把窗户拆掉就可以了。然后镜像再次激活。
Just remove the window. Then mirroring gets active again.