简体   繁体   中英

scrollview is not scrolling in autolayout xcode 6.4

I am using UIScrollview and top of a UIView but scrolling is not working. 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 . 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 . 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

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

then in .m file

@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.

scrollview.ContentSize = CGContentSize(0, height);

--> Give height as float or integer as how much you want to scroll your scrollview.

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.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滚动,您必须取消选中XIB中的“使用自动布局”复选框。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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