我有一个带有矩形框架的scrollView来显示一组子视图并对其进行分页,我希望其他子视图被隐藏,并且仅显示当前内容,但我将所有这些重叠显示在屏幕上。
if scrollViewHasBeenSetUp == false {
var index = 0
for event in eventList.events {
let match = getMatchCell(event)
match.frame = CGRect(x: index * Int(matchScrollView.frame.width), y: 0, width: Int(matchScrollView.frame.width), height: Int(matchScrollView.frame.height))
matchScrollView.contentSize = CGSize(width: Int(match.frame.width) * eventList.events.count, height: 120)
matchScrollView.addSubview(match)
index++
print("cell frame: \(match.frame)")
}
scrollViewHasBeenSetUp = true
}
使用视觉检查器,您可以看到scrollViews框架已正确设置,但其内容仍未被隐藏。
最佳答案
您是否选择了剪辑子视图?
而且我看到您的y始终为0,是垂直滚动视图吗?
关于ios - UIScrollView没有隐藏内容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35083791/