iOS horizontal UIScrollbar with Autolayout [closed

2020-02-07 12:54发布

I creating iOS app, which have showing some pictures. I am using Storyboard with Autolayout. I created view in which I add UIScroolView to specific position. In this view I am adding programmaticaly pictures depending on showing data. Basically it is UIView, to witch I am adding UIImageViews with pictures.

After I fill it, I can't scroll it to the right. I have set insects of scrollview to right, enable scrolling. I try many stuffs, but it is still don't working.

Can you help me? Thanks.

1条回答
做自己的国王
2楼-- · 2020-02-07 13:09

You have to add constraints programmatically if you want to achieve scrolling. And each side of your scroll view has to have at lest one constraint tied to it. So for example if you have 2 images you would have 3 horizontal constraints: |-firstImage-secondImage-| and 2 vertical constraints for every image: V:|-fistImage-| and V:|-secondImage-|. This way you can set the content size of your scroll view. You can find the Apple's guide here.

查看更多
登录 后发表回答