2010-12-21 14 views
4

ビューのすべての内容を整列させる方法。私は回転しているときに、iPadのコンテンツは、この問題を解決する方法自己それを中心に整列されていないのですか?UIView - UIViewのすべてのコンテンツを中央揃えにしますか?

ありがとうございました!

+0

nibファイルを使用しているのですか、それともプログラムで追加しますか? – shannoga

+0

これはnibファイルを使用しています。私はこれのためのアライメントプロパティがあることを知っているが、これを設定することによって、私はまだ回転後も同じ問題に直面している。 –

答えて

7

didRotateFromInterfaceOrientation方法とセンターのすべてのサブビューの実装を提供します あなたはこれのように試すことができます。

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    for(UIView *subview in [self.view subviews]) { 
     subview.center = self.view.center; 
    } 
} 
0

風景モードとポートレートモードの両方についてコンテンツのフレームをプログラム的に変更する必要があります。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){ 
     // set contents' frame for landscape 
    } 

    else { 
     // set contents' frame for portrait 

    } 

    return YES; 
} 
関連する問題