【问题标题】:Size classes and scroll view - cannot handle with scroll view大小类和滚动视图 - 无法处理滚动视图
【发布时间】:2015-06-17 18:42:59
【问题描述】:
我正在做具有尺寸等级的通用应用程序。它在 5 到 6 Plus 的 iPhone 上看起来相当不错。但是我需要一个4S的卷轴。所以我添加了一个滚动视图,就像advice here 一样。但我的卷轴无法在 iPhone 5-6Plus 上修复。它有点滚动。但我希望它只在 4S 上可用。我用它做不止一天,我尝试了不同类型的约束,但没有任何帮助。请给我一些建议。
【问题讨论】:
标签:
ios
iphone
uiscrollview
constraints
【解决方案1】:
您可以在 iPhone 5/6/.. 上将滚动视图的 contentSize 属性设置为滚动视图本身的高度/宽度。
// determine which device (here just schematically) ...
switch (device)
{
case "iPhone 4S":
// ...
default: // means that the user has an iPhone 5 / 6 / ... / iPad / ...
scrollView.contentSize = CGSize(width: scrollView.frame.width, height: scrollView.frame.height)
scrollView.bounces = false
// make sure that the scrollView does not show vertical/horizontal scroll indicators ...
}
那么scrollView的大小和它的contentSize的Size是相等的,所以你应该不能在里面滚动。要确定您的设备类型,请使用例如Determine device (iPhone, iPod Touch) with iPhone SDK