将 UIScrollView 发送到后台 [英] sending UIScrollView to Background

查看:37
本文介绍了将 UIScrollView 发送到后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在完成我的应用程序.我注意到我的一个视图需要额外的垂直空间,所以我需要添加一个 UIScrollView.然而,当我添加该滚动视图时,它会与视图中的其他所有内容重叠.简单来说,如果我需要让它正常工作,我必须从视图中删除所有内容,添加滚动视图,然后重新添加所有内容!有没有办法将此滚动视图发送到视图的背景?这是所有涉及滚动视图的代码

I'm midway of finishing my app. I noticed that one of my views needs extra vertical space so I need to add a UIScrollView. Yet when I add that scroll view it overlaps everything else in the view. In simple words if I need to get it to work properly I have to delete everything off the view , add the scroll view, and then re-add everything back! Is there anyway to send this scroll view to the background of the view? This is all the code that concerns the scroll view

@IBOutlet var scrollerForPOfFourBar: UIScrollView!

override func viewDidLoad() {
    super.viewDidLoad()
    /* non related code here*/

    scrollerForPOfFourBar.userInteractionEnabled = true
    scrollerForPOfFourBar.self.contentSize = CGSizeMake(320, 400)
}

推荐答案

我假设您正在使用 Interface Builder,因为您将 scrollView 标记为 IBOutlet.

I'm assuming you're using Interface Builder since you marked your scrollView as an IBOutlet.

在左侧的视图列表中,视图的顺序指定了它们的 Z 顺序,底部的视图是绘制在顶部的视图(Z 最大).

On the view list, on the left, the order of the views specifies their Z order, with the views at the bottom being the ones drawn on top (with the largest Z).

要将 scrollView 移到后面,请将其拖动到视图下方,然后将其放在那里.

To move your scrollView to the back, drag it just underneath of the view, and drop it there.

请记住,您必须将视图中的所有视图拖到滚动视图中(最简单的方法是在视图导航器中进行),并且您必须设置任何自动布局约束再次,这是痛苦的.

Keep in mind that you will have to drag all the views you had in your view into the scrollView (the easiest is to do it in the views navigator as well), and you'll have to set up any Auto Layout constraints again, which will be a pain.

这篇关于将 UIScrollView 发送到后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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