带有自动布局的 iOS 水平 UIScrollbar

iOS horizontal UIScrollbar with Autolayout(带有自动布局的 iOS 水平 UIScrollbar)

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

问题描述

我正在创建 iOS 应用程序,其中显示了一些图片.我正在使用带有自动布局的情节提要.我创建了将 UIScoolView 添加到特定位置的视图.在此视图中,我将根据显示数据以编程方式添加图片.基本上它是 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.

这篇关于带有自动布局的 iOS 水平 UIScrollbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:带有自动布局的 iOS 水平 UIScrollbar

基础教程推荐