更新:这是一个iOS 10问题。这仍然可以在iOS 9中使用。iOS 10期:UIScrollView不滚动,即使设置ContentSize时
这是......有趣的。
我只是转换我的“教学计划”(“玩具”的应用程序),以斯威夫特3.
它一直致力于为雨燕1.2在一两年。
突然间,我的UIScrollView没有滚动,即使当我将contentSize方法设置为超越其下限时。
这里的有关代码(displayTags程序被调用与被显示为中心并且稍微垂直偏移图像的阵列,导致竖直链):
/*******************************************************************************************/
/**
\brief Displays the tags in the scroll view.
\param inTagImageArray the array of tag images to be displayed.
*/
func displayTags (inTagImageArray:[UIImage])
{
self.tagDisplayView!.bounds = self.tagDisplayScroller!.bounds
if (inTagImageArray.count > 0) // We need to have images to display
{
var offset:CGFloat = 0.0 // This will be the vertical offset for each tag.
for tag in inTagImageArray
{
self.displayTag (inTag: tag, inOffset: &offset)
}
}
}
/*******************************************************************************************/
/**
\brief Displays a single tag in the scroll view.
\param inTag a UIImage of the tag to be displayed.
\param inOffset the vertical offset (from the top of the display view) of the tag to be drawn.
*/
func displayTag (inTag:UIImage, inOffset:inout CGFloat)
{
let imageView:UIImageView = UIImageView (image:inTag)
var containerRect:CGRect = self.tagDisplayView!.frame // See what we have to work with.
containerRect.origin = CGPoint.zero
let targetRect:CGRect = CGRect (x: (containerRect.size.width - inTag.size.width)/2.0, y: inOffset, width: inTag.size.width, height: inTag.size.height)
imageView.frame = targetRect
containerRect.size.height = max ((targetRect.origin.y + targetRect.size.height), (containerRect.origin.y + containerRect.size.height))
self.tagDisplayView!.frame = containerRect
self.tagDisplayView!.addSubview (imageView)
self.tagDisplayScroller!.contentSize = containerRect.size
print ("Tag Container Rect: \(containerRect)")
print (" Tag ScrollView Bounds: \(self.tagDisplayScroller!.bounds)")
inOffset = inOffset + (inTag.size.height * 0.31)
}
注意,滚动视图的contentSize是每个扩展时间标签被添加。我检查了一下(看打印报告),这个值似乎是正确的。
The project itself is completely open-source.
This is where this issue manifests(我有其他错误,但在我这个钉子一个我会找固定它们)。
我敢肯定,我正在做一些明显的和骨头的事情(通常是这种情况)。
任何人有任何想法?
我认为问题是与uiview,你没有设置高度.. – Do2
我会检查出来。故事板中的高度已设置(并在构建时移除),但我不在此处设置。这是完全可能的,你是正确的。我发现在操作系统升级中,无证件(或未明确说明)的东西通常会发生变化。我只在iOS 10中测试过它。我想知道它是否会在iOS 9中再次运行?如果是这样,我还有另一个需要调整的应用程序。谢谢! –
嗯,我刚刚检查出来。适用于9.3,但不适用于10.操作系统引入了曲线球。正在设置高度(请参阅我设置框架)。我需要弄清楚为什么iOS 10突然不喜欢这样。我在另一个应用中做了几乎完全相同的事情,我很担心。 –