简体   繁体   English

scrollview在自动布局Xcode 6.4中不滚动

[英]scrollview is not scrolling in autolayout xcode 6.4

I am using UIScrollview and top of a UIView but scrolling is not working. 我正在使用UIScrollview和UIView的顶部,但是滚动不起作用。 for scrollview i added constraints all the side (0,0,0,0) then i have take container view and adedd constraints for (0,0,0,0) for all side . 对于scrollview,我在所有侧面都添加了约束(0,0,0,0),然后我在所有侧面添加了容器视图和(0,0,0,0)的附加约束。 and one more constraints i added for this container view to View with equal width. 我为此容器视图添加了另一个约束,以等宽的视图。

在此处输入图片说明

my scrollview hight is 504 and containner hight is 840. i am not getting any warning and suggestion constraints but not able to scroll . 我的scrollview的最高值是504,容器的最高值是840。我没有得到任何警告和建议约束,但不能滚动。 what is missing here .Please suggest me . 这里缺少什么。请建议我。

在此处输入图片说明

在此处输入图片说明

if you have added constraints properly . 如果您已正确添加约束。 then add this 然后添加这个

make property or your scrolview and container view as 使财产或您的scrolview和容器视图为

@property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
@property (weak, nonatomic) IBOutlet UIView *containerview;

then in .m file 然后在.m文件中

@synthesize scrollview,containerview,

then add this 然后添加这个

-(void)viewDidAppear:(BOOL)animated
{
    [scrollview setContentSize:CGSizeMake(scrollview.frame.size.width, containerview.frame.size.height)];
}

I hope the will solve your issue. 希望能解决您的问题。

There is no problem with autolayout in x-code 6.4 just try to check that you have properly bind the outlets of scrollview as well as give contentsize to scrollview that how much you would like to scroll your scrollview. 在x代码6.4中,自动布局没有问题,只需尝试检查您是否已正确绑定scrollview的出口,并为contentview赋予contentsize您想滚动多少scrollview。

scrollview.ContentSize = CGContentSize(0, height);

--> Give height as float or integer as how much you want to scroll your scrollview. ->将高度设置为float或integer作为要滚动滚动视图的高度。

For the ScrollView to work, reference it to your .h file by CTRL + Dragging the scroll view, and on your .m file add a 为使ScrollView正常工作,请通过CTRL +拖动滚动视图将其引用到.h文件,然后在.m文件上添加一个

scrollView.contentSize(0,doubleTheSizeOfTheViewHeight);

if you want the scroll to be scrollable horizontally do the same with the width. 如果您希望滚动条可水平滚动,请对宽度进行相同操作。

Hope this helps 希望这可以帮助

Update Or you can always use this for the storyboard way of doing it: Storyboard UIScrollView contentSize? 更新或者您始终可以将其用作情节提要的实现方式: 情节提要UIScrollView contentSize?

要使UIScrollview滚动,您必须取消选中XIB中的“使用自动布局”复选框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM