UIScrollView无法在Swift中滚动 [英] UIScrollView not scrolling in Swift
本文介绍了UIScrollView无法在Swift中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的UIScrollView不会向下滚动.我不知道为什么我已经关注了有关此问题的Apple文档.
My UIScrollView won't scroll down. I don't know why. I already followed Apple documentation regarding to this issue.
@IBOutlet weak var scroller: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidLayoutSubviews() {
scroller.scrollEnabled = true
// Do any additional setup after loading the view
scroller.contentSize = CGSizeMake(400, 2300)
}
推荐答案
您需要将UIScrollView
的frame
设置为小于contentsize
.否则,它将不会滚动.
You need to set the frame
of your UIScrollView
so that it is less than the contentsize
. Otherwise, it won't scroll.
此外,我建议您将scroller.contentSize = CGSizeMake(400, 2300)
添加到viewDidLoad
方法中.
Also, I would recommend that you add scroller.contentSize = CGSizeMake(400, 2300)
to your viewDidLoad
method.
这篇关于UIScrollView无法在Swift中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文