2012-10-13 100 views
2

所以我有一个UIViewView里面的UIViewView里面我添加了一个UIView它里面,我希望它总是坚持在底部,无论方向的变化。所以,我有以下几点:UIView坚持在UIScrollView底部

enter image description here

的问题是,当我旋转到景观,滚动视图内容大小高度肯定会大于帧的高度更大,因此向下滚动。然而,这个UIView,我想坚持在底部不会坚持。无论方向如何变化,我如何使它始终坚持到底部。

当我禁用的UIScrollView AUTORESIZE子视图,此UIView的粘在底部,但旋转

当宽度不调整

回答

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 
    } 
} 
2

你应该尝试使用编码使用自动调整大小面具以下方式

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

或IB加上顶部,左侧,博特m和右边缘灵活性。

或以其他方式将视图按照您的要求放置在willRotateToInterfaceOrientation方法中。