开发者

Scroll View ignoring contentInset for large content areas

开发者 https://www.devze.com 2023-04-09 14:46 出处:网络
I have an app which loads in a grid of images. I\'ve used contentInset so that I have a nice 10pt margin at the top. When I load in an array of images that total less that the scrollView area, it work

I have an app which loads in a grid of images. I've used contentInset so that I have a nice 10pt margin at the top. When I load in an array of images that total less that the scrollView area, it works great. But when I load in an array of images that total more than the scrollView area, it completely ignores the contentInset value.

If I scroll down then back up it then acknowledges the fact there is a margin there. I'm going out of my mind trying to find out why. Anyone experienced this before?

float tempNumber = ((float)[faceArray count] / 3);
int numberOfRows = ceil(tempNumbe开发者_JAVA技巧r);

// CGSizeMake (x, y, w, h)
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, 
                          (numberOfRows * (kThumbSpace + kThumbnailSize)));
scrollView.pagingEnabled = NO;
scrollView.showsVerticalScrollIndicator = YES;
scrollView.delegate = self;
scrollView.contentInset = UIEdgeInsetsMake(10.0, 0, 0, 0);
scrollView.alwaysBounceVertical = YES;

//.... code is then sent to a method which creates the grid of subviews in order
//     to fill the scrollView


You could set the contentOffset property so that the scroll view always starts in the right position. It looks like it is automatically moving itself to show you as many subviews as possible, not sure if that is a setting somewhere you could change.

0

精彩评论

暂无评论...
验证码 换一张
取 消