0
我在Github上看了一些例子,但他們都沒有故事板的用法。在外部顯示器上顯示屏幕
我試着在我的應用程序中使用該代碼,但我在模擬器的外部設備上看到的所有內容都是黑屏。
代碼我現在有:
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;
[self myScreenInit:externalScreen];
}
- (void) screenDidConnect:(NSNotification *)notification {
[self myScreenInit:[notification object]];
}
- (void) myScreenInit:(UIScreen *)connectedScreen {
CGRect frame = connectedScreen.bounds;
UIWindow *window = [[UIWindow alloc] initWithFrame:frame];
window.backgroundColor = [UIColor whiteColor];
[window setScreen:connectedScreen];
window.hidden = NO;
}
謝謝,但問題是,如果我使用故事板它不工作... – Shmidt 2012-08-07 21:07:05