将子视图添加到外部屏幕(iOS5)
我有一个名为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
知道了。 UIWindow 必须被定义为全局!
Got it. The UIWindow has to be defined GLOBALLY!
查看此示例代码:
https://github.com/quellish/AirplayDemo
这几乎可以满足您的需求。
Check out this sample code:
https://github.com/quellish/AirplayDemo
That does pretty much what you're looking for.