当我的iPhone / iPad连接到外部显示器时会出现这种情况。
在正常情况下,整个设备的屏幕都会镜像到外部显示器。但是,对于特定的视图/页面,我需要外部显示器上的屏幕显示与设备中的内容不同的内容。
我在UIScrollView中有一个UIImageView,以及一些相关的按钮(下一个,上一个等)作为应用程序的特定视图控制器的一部分。我希望外部设备只显示UIScrollView中的内容(也就是说,不显示按钮)。为此,我似乎必须为外部显示屏创建另一个UIWindow实例。
但是,如何在外部显示器中制作UIWindow(及其内容)以相应地响应对主UIWindow(在iPhone / iPad中显示的那个)所做的更改。也就是说,更改如放大和缩小。
答案 0 :(得分:0)
你可以这样做:
- (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;
// Set up initial content to display...
secondWindow.rootViewController = [ExternalScreenViewController sharedExternalScreen];
// Show the window.
self.secondWindow.hidden = NO;
}
}
现在您需要做的就是使用填充整个viewController的UIView创建ExternalScreenViewController
。最后,您只需将目标视图设置为等于scrollView的视图。