2

そのため、UIViewController の UIView 内に UIScrollView があり、その中に UIView を追加しました。向きの変更に関係なく、常に下部に固定するようにしました。だから私は以下を持っていました:

ここに画像の説明を入力

問題は、横向きに回転すると、スクロール ビューのコンテンツ サイズの高さがフレームの高さよりも確実に大きくなるため、下にスクロールすることです。しかし、一番下に貼り付けたいUIViewが貼り付きません。向きの変化に関係なく、常に下にくっつくようにするにはどうすればよいですか。

UIScrollView サブビューの自動サイズ変更を無効にすると、この UIView は下部にくっつきますが、回転しても幅が調整されません

4

2 に答える 2

2

次の方法で自動サイズ変更マスクを使用してみてください

yourview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;

コーディングを使用するか、IB で上、左、下、右のマージンの柔軟性を追加します。

または、 willRotateToInterfaceOrientation メソッドの要件に従ってビューを配置します。

于 2012-10-16T12:05:48.230 に答える
1

orientations以下の例に従ってフレームを調整する必要があります-

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{
    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        //set your portrait frame here and also the content size of scrollView
    }
    else
    {
        //set your Landscape frame here and also the content size of scrollView
    } 
}
于 2012-10-13T05:23:05.613 に答える