How can I re-enable app mirroring on my iPad application after I use the external display to show unique content?
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
shareVi开发者_运维问答ewController.view.frame = secondWindow.frame;
[secondWindow addSubview:shareViewController.view];
secondWindow.hidden = NO;
}
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.
// 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];
Just remove the window. Then mirroring gets active again.
secondWindow = nil;
精彩评论