2013-04-05 26 views
0

我正在使用AirPlay,iPad的主要內容被AppleTV罰款。設置UIScreen後保持UIWindow大小值

當我想要在iPad上的不同信息比在AppleTV上,我得到解決問題。

我實例化的UIWindow:

_atvWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 2048, 1536)]; 

的NSLog表示窗口是幀大小我想

我的一個UIWindow設置爲iPad屏幕

_atvWindow.screen = [[UIScreen screens] objectAtIndex:0]; 

NSLog的指示窗框現在是1024x768

這是一個視網膜iPad。我希望大小保持視網膜和相應的設置圖像。一旦我添加視網膜質量的圖像,他們(如你所料)的方式太大了。任何想法是什麼導致這個或我在這裏失蹤?

回答

0

您是否嘗試從[通知對象]對象中的屏幕讀取幀大小?

- (void)handleConnectedScreen:(UIScreen *)screen withViewController:(UIViewController *)controller { 
    if(!_airPlayWindow) 
    { 
     CGRect frame = screen.bounds; 
     _airPlayWindow = [[UIWindow alloc] initWithFrame:frame]; 
     _airPlayWindow.backgroundColor = [UIColor clearColor]; 
     [_airPlayWindow setScreen:screen]; 
     _airPlayWindow.hidden = NO; 
    } 

    UIViewController *oldController = _airPlayWindow.rootViewController; 
    [_airPlayWindow setRootViewController:controller]; 
    [oldController removeFromParentViewController]; 
} 


- (void)screenDidConnect:(NSNotification *)notification { 
    ABOutputViewController *c = [[ABOutputViewController alloc] init]; 
    [self handleConnectedScreen:[notification object] withViewController:c]; 
} 


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidConnect:) name:UIScreenDidConnectNotification object:nil];