Как исправить «пустую» область, когда navigationBarHidden = NO - PullRequest
1 голос
/ 11 июня 2009

Я вращаю вид, похожий на приложение iTunes. На портрете вид из таблицы, а в пейзаже - просмотрщик фотографий.

Когда я возвращаюсь из пейзажа в портрет, я пытаюсь восстановить панель навигации, но вместо этого получаю искаженное представление таблицы, но не панель навигации.

Вот что я делаю:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                            duration:(NSTimeInterval)duration {
BOOL restoreNav = NO;

if ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || 
    (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) {
    [self inPortrait];
    restoreNav = YES;
} else {
    [self inLandscape];
}

if (self.landscape)
{
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
    {
        self.view = self.portrait;
    }
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    {
        self.view = self.landscape;
    }
    else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        self.view = self.portrait;
    }
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        self.view = self.landscape;
    }       
    [[self.navigationController view] setFrame: [[UIScreen mainScreen] bounds]];
} else {
    self.navigationController.navigationBarHidden = NO; 
}

[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

1 Ответ

1 голос
/ 13 июня 2009

Я нашел полфикс в этом вопросе в http://www.iphonedevsdk.com/forum/iphone-sdk-development/3262-horrible-drawing-after-hiding-navigationbar.html

Это соответствующий код:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
//total hack - to fix the bug where the screen layout is shagged if the device orientation
//is changed when the navigation is hidden

if ([self.navigationController isNavigationBarHidden])
{
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    [self.navigationController setNavigationBarHidden:TRUE animated:NO];
}

}

Тем не менее, это опять грязно, если появляется навигационная панель.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...