1

アプリケーションにページングがあります。画像のある各ページ。オリエンテーション中に、横向きと縦向きに応じてフレームを変更しています。しかし、画像は跳ねています。バウンドせずスムーズにセットしたい。

私に何ができるか教えてください。

フレームを変えています

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

ここにいくつかのコードがあります。

 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
        if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
        {
            [self performSelector:@selector(setLandscapeOrientationFrame) withObject:nil afterDelay:(duration/2)];
        }
        else
        {
            [self performSelector:@selector(setPortraitOrientationFrame) withObject:nil afterDelay:(duration/2)];
        }

    }

そして「setPortraitOrientationFrame」と「setLandscapeOrientationFrame」ではフレームを変えています。

4

2 に答える 2

1

iOS6 を使用している場合は、 autolayout を使用できます。その理由は、遅延を使用したことが原因である可能性があります。次のコードを使用すると、動作する可能性があります。

`- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
 {

     if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
     {
         [self setLandscapeOrientationFrame];
     }
     else
     {
         [self setPortraitOrientationFrame];
     }

}
于 2013-05-03T05:12:56.373 に答える
0

取り組んでいiOS6+ますか?はいの場合は、その機能に従うことをお勧めしますautoLayoutiOS 6 の自動レイアウトの開始を 1 つずつ実行すると、 の美しさが理解できますautoLayoutautoLayoutコードでフレームの位置を手動で設定する必要はありません。

于 2013-05-03T05:37:01.437 に答える