2013-04-05 72 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]; 
相关问题