1

私は誰かが助けてくれることを願っている奇妙なものを持っています。横向きに回転するとNavigationBarを非表示にするアプリがあります...

-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if( toInterfaceOrientation == UIInterfaceOrientationPortrait )
    {
        self.view = portraitView;

    }
    else if( toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft )
    {
        self.view = landscapeRightView;
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    }

これは正常に機能し、NavBar は消えます。問題は、回転して縦向きに戻すと、NavBar が再表示されますが、ビューの中央で垂直になり、画面の上部で水平になりません!!! NavBar の再表示をどこに配置しても (回転後、前半後)、縦向きビューに戻ると、常に向きと場所が間違っています。

縦向きに戻す回転に関する私のコードは次のとおりです。

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if( self.view == portraitView )
{
     [self.navigationController setNavigationBarHidden:NO animated:NO];
}
}

誰でもアイデアを提供できますか?これは私を夢中にさせています!

4

1 に答える 1

0

両方を確認してください

if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)

{} else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)

{}

于 2011-05-25T12:18:22.210 に答える