Запазете размера на UIWindow, след като зададете стойността му на UIScreen

Използвам AirPlay, основното съдържание на iPad се предава добре на AppleTV.

Когато искам различна информация на iPad от тази на AppleTV, получавам проблеми с разрешаването.

Инстанцирам UIWindow:

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

NSLog показва, че прозорецът е с размера на рамката, който искам

Настроих UIWindow на екрана на iPad

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

NSLog показва, че рамката на прозореца вече е 1024x768

Това е iPad с ретина. Искам размерът да остане ретина и съответно зададените изображения. След като добавя изображения с качество на ретината, те са (както бихте очаквали) твърде големи. Някакви идеи на какво се дължи това или какво пропускам тук?


person chillok    schedule 05.04.2013    source източник


Отговори (1)


Опитвали ли сте да прочетете размера на рамката от екрана, който идва във вашия обект [notification object]?

- (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];
person Ondrej Rafaj    schedule 11.06.2013