在两个屏幕上运行的iOS应用程序(无镜像)

前端之家收集整理的这篇文章主要介绍了在两个屏幕上运行的iOS应用程序(无镜像)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个包含幻灯片的iPad应用程序,当用户点击此幻灯片时,他/她可以输入一些信息.

我现在要做的是在通过AirPlay连接电视和iPad时在电视上显示幻灯片显示内容(如果可能的话,还可以连接电缆,但这似乎只是镜像事物)

可以这样做吗?我们是否可以在电视和iPad上播放幻灯片,然后当用户点击iPad上的幻灯片时,凭据输入屏幕将显示但在电视上仍会显示基础幻灯片不显示凭据?

如何在iOS中完成?是否可以在电视上显示部分应用程序?所以不要反映整个应用程序.

解决方法

您可以使用Airplay和Apple TV编写应用程序以处理2个UIScreens,然后为电视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]];
}
原文链接:https://www.f2er.com/iOS/331160.html

猜你在找的iOS相关文章