UIView坚持在UIScrollView的底部 [英] UIView to stick at bottom of UIScrollView

查看:147
本文介绍了UIView坚持在UIScrollView的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在UIViewController的UIView里面有一个UIScrollView,里面我添加了一个UIView,我希望它始终坚持在底部而不管方向的变化。所以我有以下内容:

So I have a UIScrollView inside a UIView of a UIViewController in which I added a UIView inside it, and I wanted it to always stick at the bottom regardless of the orientation changes. So I had the following:

问题在于,当我旋转到横向时,滚动视图内容大小高度肯定会大于框架高度,因此它会向下滚动。然而,我想要坚持在底部的这个UIView并不坚持。如何使它始终坚持到底部而不管方向的变化。

The issue is that when I rotate into landscape, the scroll view content size height is definitely going to be bigger than the frame height, and therefore it scrolls down. However this UIView that I want to stick at the bottom doesn't stick. How do I make it so that it always stick to the bottom regardless of the orientation changes.

当我禁用UIScrollView autoresize子视图时,这个UIView坚持到底部,但是旋转时宽度不会调整

When I disabled UIScrollView autoresize subviews, this UIView sticks to the bottom, but the width doesn't adjust when rotated

推荐答案

您必须根据方向调整框架见下面的例子 -

You will have to adjust frame according to orientations see below example -

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

这篇关于UIView坚持在UIScrollView的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆