带有Autolayout的iOS水平UIScrollbar [英] iOS horizontal UIScrollbar with Autolayout

查看:114
本文介绍了带有Autolayout的iOS水平UIScrollbar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建iOS应用,其中显示了一些图片。我在Autolayout中使用Storyboard。我创建了一个视图,其中我将UIScroolView添加到特定位置。在这个视图中,我根据显示数据添加programmaticaly图片。
基本上它是UIView,巫婆我正在添加带图片的UIImageViews。

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.

填完后,我无法向右滚动它。我已将scrollview的昆虫设置为右侧,启用滚动。我尝试了很多东西,但它仍然没有用。

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.

你能帮助我吗?谢谢。

推荐答案

如果要实现滚动,必须以编程方式添加约束。滚动视图的每一面都必须至少有一个约束。因此,例如,如果您有2个图像,则会有3个水平约束: | -firstImage-secondImage- | 和每个图像的2个垂直约束: V :| -fistImage- | V:| -secondImage- | 。这样,您可以设置滚动视图的内容大小。你可以在这里找到Apple的指南这里

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.

这篇关于带有Autolayout的iOS水平UIScrollbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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