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

发布于 2024-12-13 05:34:04 字数 268 浏览 1 评论 0原文

我创建了一个 iPad 应用程序,其中包含幻灯片,当用户点击该幻灯片时,他/她可以输入一些信息。

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

可以这样做吗?我们能否让幻灯片在电视和 iPad 上运行,然后当用户点击 iPad 上的幻灯片时,凭据输入屏幕将显示,但在电视上仍然会显示底层幻灯片而不是凭据?

在 iOS 中如何做到这一点?是否可以在电视上显示应用程序的一部分?所以不镜像整个应用程序。

I've created an iPad app which contains a slideshow and when this slideshow is tapped by the user he/she can entered some information.

What I'd like to do now is to display the slideshow contents on a TV when connecting the TV and iPad through AirPlay (or cable if possible, but that only seems to mirror things)

Can this be done? Can we have the slideshow run on the TV and also on iPad and then when the user taps the slideshow on the iPad the credentials input screen will show but on TV still the underlying slideshow will show and not the credentials?

How can this be done in iOS? Is it possible to display a portion of the application on the TV? So not mirroring the entire application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼趣 2024-12-20 05:34:04

您可以编写应用程序来使用 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]];
}

You can write the app to handle 2 UIScreens using Airplay and an Apple TV then set a seperate root view controller for both the TV UIScreen and for the iPad UIScreen. Then display the image or slideshow on the TV's view controller and run that from the events of you iPads view controller!

AMENDED AFTER CLIFS COMMENT:

So firstly in your app delegate in didFinishLaunchingWithOptions or didFinishLaunching setup a notification to receive the screen did connect.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidConnect:) name:UIScreenDidConnectNotification object:nil];

Then you need to keep a reference to your separate window and push controllers to it as you would any other window.

- (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]];
}
梦醒时光 2024-12-20 05:34:04

iOS 5.0 中似乎存在一个错误,这使得这个问题变得棘手。您必须从正在运行的任务栏启用镜像(在通过 API 检测到第二个屏幕之前一直向左滚动)。我已在此处的问题中发布了详细信息:如何在第二个屏幕上使用 iOS 5+ AirPlay

There appears to be a bug in iOS 5.0 which makes this tricky. You have to enable mirroring from the running task bar (scrolling all the way the left before a second screen is detected via the API. I've posted details in my question here: How to use iOS 5+ AirPlay for a second screen

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文