ios - 将 subview 添加到外部屏幕(iOS5)

标签 ios xcode addsubview uiscreen

我有一个 View Controller ,称为 TVOutViewController (.h & .m),它应该处理我的外部屏幕。我如何“告诉” View Controller 这样做?

我已经做了什么:

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

谢谢!

最佳答案

明白了。 UIWindow 必须全局定义!

关于ios - 将 subview 添加到外部屏幕(iOS5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7938456/

相关文章:

ios - 滑过 UI 模式或组件的名称

ios - 为什么我的 Swift 程序停滞不前?

ios - SwiftUI 更改 ScrollView 中按钮的背景颜色

ios - xcode 构建错误 : swiftc failed with exit code 1

ios - Swift:在 Tableview 的特定单元格中添加子层而不是每个单元格

ios - 在 didSelectRowAtIndexPath 中添加 subview

ios - 拖动进入时突出显示按钮

ios - 万向节示例项目 (Mallmart) 架构 armv7 的 undefined symbol :

iphone - 如何使用 [self.view addSubview : myView] where myView is subclass of UIView? 添加 subview

objective-c - 如何在 Xcode 中访问或操作一个类的变量