2

私はiPhoneでアプリケーションを開発しています。1 つのビューは、縦向きと横向きの向きをサポートします。両方の向きに 2 つの別々のビューがあります。このビューUIToolbarの上部には があります。

問題は、ビューを横向きから縦向きに戻すUIToolbarと、上部が消えることです。toolbar縦向きに回転させたときに元の位置に戻ってほしい。

これは私が私のプログラムでやっていることです:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {    
    if (interfaceOrientation == UIInterfaceOrientationPortrait)
    {
        self.view = self.portrait;
        self.view.transform = CGAffineTransformIdentity;
        self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
        self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);  
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    {
        self.view = self.landscape;
        self.view.transform = CGAffineTransformIdentity;
        self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
        self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
    }
    else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        self.view = self.portrait;
        self.view.transform = CGAffineTransformIdentity;
        self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
        self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        self.view = self.landscape;
        self.view.transform = CGAffineTransformIdentity;
        self.view.transform = 
        CGAffineTransformMakeRotation(degreesToRadian(90));
        self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
    }
}

ここで何が足りないのかわからない?どんな助けでも本当に感謝しています。

4

3 に答える 3

2

インターフェイス ビルダーで、ツールバーを選択し、command-3 を押します。これにより、ルーラー/配置コントロール メニューが表示されます。

Autsizing セクションでは、デフォルトで、ツールバーは左右と中央にのみ結合されています。トップにはありません。上部の「I」を選択します。現在、ツールバーはビューの上部に対してドッキングされており、回転中に押し出されることはありません。

これにも相当するコードがあると確信しています

于 2010-08-10T14:07:52.100 に答える
1

ビューを回転可能にしたいだけなら、実装するのに十分です

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return YES;
}

viewCountrollerクラスで

于 2009-11-29T03:38:53.457 に答える
1
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);  

ここでの問題は、高さを 480 にしていることです。しかし、460 にする必要があります。したがって、現在、高さが 20px 以上あり、これにより、トップバーが画面から多少外れている可能性があります。

于 2009-11-29T07:48:24.730 に答える