1

我有一个视图控制器,称为 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

谢谢!

4

2 回答 2

0

知道了。UIWindow必须在全球范围内定义!

于 2011-11-04T17:21:20.900 回答
0

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

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

于 2012-06-02T05:54:03.657 回答