将子视图添加到外部屏幕(iOS5)

发布于 2024-12-12 18:03:24 字数 1019 浏览 0 评论 0原文

我有一个名为 TVOutViewController (.h & .m) 的视图控制器,它应该处理我的外部屏幕。我如何“告诉”视图控制器这样做?

我已经做了什么:

NSLog(@"Current Number of screens: %i", [[UIScreen screens] count]);


if([[UIScreen screens]count] > 1) {

    CGSize maxSize;
    UIScreenMode *maxScreenMode;

    for(int i = 0; i < [[[[UIScreen screens] objectAtIndex:1] availableModes]count]; i++)
    {
        UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:i];
        if(current.size.width > maxSize.width)
        {
            maxSize = current.size;
            maxScreenMode = current;
        }
    }
    UIScreen *externalScreen = [[UIScreen screens] objectAtIndex:1];
    externalScreen.currentMode = maxScreenMode;

所以我的阵列中现在有一个外部屏幕(并且已识别)。但是我如何向该屏幕添加(例如)标签?

有没有类似的方法:

 Screen Handled by the TVOutViewController = TheExternalScreen //Pseudocode
 [Screen Handled by the TVOutViewController addSubview: aLabel]; //Pseudocode

谢谢!

I have a View Controller, called TVOutViewController (.h & .m) which should handle my external Screen. How can I "tell" the View Controller to do so?

What I did already:

NSLog(@"Current Number of screens: %i", [[UIScreen screens] count]);


if([[UIScreen screens]count] > 1) {

    CGSize maxSize;
    UIScreenMode *maxScreenMode;

    for(int i = 0; i < [[[[UIScreen screens] objectAtIndex:1] availableModes]count]; i++)
    {
        UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:i];
        if(current.size.width > maxSize.width)
        {
            maxSize = current.size;
            maxScreenMode = current;
        }
    }
    UIScreen *externalScreen = [[UIScreen screens] objectAtIndex:1];
    externalScreen.currentMode = maxScreenMode;

So there is an external Screen in my array now (and recognized). But how can I add (for example) a label to this screen?

Is there a way like:

 Screen Handled by the TVOutViewController = TheExternalScreen //Pseudocode
 [Screen Handled by the TVOutViewController addSubview: aLabel]; //Pseudocode

Thank you!

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

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

发布评论

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

评论(2

睡美人的小仙女 2024-12-19 18:03:24

知道了。 UIWindow 必须被定义为全局

Got it. The UIWindow has to be defined GLOBALLY!

清浅ˋ旧时光 2024-12-19 18:03:24

查看此示例代码:
https://github.com/quellish/AirplayDemo

这几乎可以满足您的需求。

Check out this sample code:
https://github.com/quellish/AirplayDemo

That does pretty much what you're looking for.

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