UPDATE: This is a problem with iOS 10. It still works as of iOS 9.
It is interesting.
I just converted my “training project” (the “toy” application) to Swift 3.
He has been working for a couple of years in Swift 1.2.
Suddenly my UIScrollView does not scroll even when I set the contentSize path to its lower bound.
Here is the corresponding code (the displayTags procedure is called with an array of images that are displayed in the center and slightly vertically shifted, which leads to a vertical chain):
func displayTags ( inTagImageArray:[UIImage] )
{
self.tagDisplayView!.bounds = self.tagDisplayScroller!.bounds
if ( inTagImageArray.count > 0 )
{
var offset:CGFloat = 0.0
for tag in inTagImageArray
{
self.displayTag ( inTag: tag, inOffset: &offset )
}
}
}
func displayTag ( inTag:UIImage, inOffset:inout CGFloat )
{
let imageView:UIImageView = UIImageView ( image:inTag )
var containerRect:CGRect = self.tagDisplayView!.frame
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)
}
Note that scrollView contentSize expands each time a tag is added. I checked (see print instructions) and the value seems to be correct.
.
( , , ).
, - ( ).
- ?