【发布时间】:2012-09-17 20:45:36
【问题描述】:
我正在尝试在我的 iOS 应用上支持外部显示而不使用任何 .xib 文件。
现在我的代码包含以下内容:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
if ([[UIScreen screens] count] > 1){
externalScreen = [[UIScreen screens] objectAtIndex:1];
UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:0];
externalScreen.currentMode = current;
externalWindow = [[UIWindow alloc] initWithFrame:[externalScreen bounds]];
externalWindow.screen = externalScreen;
externalWindow.clipsToBounds = YES;
extController = [[ExternalController alloc] init];
[externalWindow addSubview:extController.view];
[externalWindow makeKeyAndVisible];
}
self.window = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:0] bounds]];
mainController = [[ViewController alloc] init];
[self.window addSubview:mainController.view];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
}
当我运行它时,TV Out 屏幕将立即关闭。 如果我评论这一行:
//self.window = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:0] bounds]];
TV Out 屏幕可以正常工作,但当然我的模拟器屏幕上看不到任何内容。
有人知道我应该怎么做吗?提前致谢!
【问题讨论】:
标签: ios xcode4.2 external-display