我创建了一个 iPad 应用程序,其中包含幻灯片,当用户点击该幻灯片时,他/她可以输入一些信息。
我现在想做的是通过AirPlay(或电缆,如果可能的话,但这似乎只是镜像)连接电视和iPad时在电视上显示幻灯片内容
这可以做到吗?我们能否让幻灯片在电视和 iPad 上运行,然后当用户点击 iPad 上的幻灯片时,凭据输入屏幕将显示,但在电视上仍然会显示底层幻灯片而不是凭据?
在 iOS 中如何做到这一点?是否可以在电视上显示应用程序的一部分?所以不镜像整个应用程序。
您可以编写应用程序来使用 Airplay 和 Apple TV 处理 2 个 UIScreen,然后为 TV UIScreen 和 iPad UIScreen 设置单独的根视图控制器。然后在电视的视图控制器上显示图像或幻灯片,并从 iPad 视图控制器的事件中运行它!
CLIFS 评论后修改:
因此,首先在 didFinishLaunchingWithOptions 或 didFinishLaunching 中的应用程序委托中设置一个通知以接收屏幕确实连接。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidConnect:) name:UIScreenDidConnectNotification object:nil];
然后,您需要保留对单独窗口的引用,并将控制器推送到它,就像处理任何其他窗口一样。
- (void) myScreenInit:(UIScreen *)connectedScreen:(UIViewController*)mynewViewController
{
//Intitialise TV Screen
if(!windowTV)
{
CGRect frame = connectedScreen.bounds;
windowTV = [[UIWindow alloc] initWithFrame:frame];
windowTV.backgroundColor = [UIColor clearColor];
[windowTV setScreen:connectedScreen];
windowTV.hidden = NO;
}
UIViewController* release = windowTV.rootViewController;
windowTV.rootViewController = mynewViewController;
[release removeFromParentViewController];
[release release];
}
- (void)setTvController:(UIViewController*)mynewViewController
{
UIViewController* release = windowTV.rootViewController;
windowTV.rootViewController = mynewViewController;
[release removeFromParentViewController];
[release release];
}
- (void)screenDidConnect:(NSNotification *)notification {
[self myScreenInit:[notification object]];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)