views:

585

answers:

1

Before I scroll, my UIScrollView is laid out perfectly. See here

However if I scroll up, the view bounces as I go out of bounds and then resets too high. See here

I am going to guess this has to do with a hack that I did earlier to get the view to originally show like in the first screen shot. For some reason, to get my view to look like the second screen shot, I do:

[scrollView setContentOffset:CGPointMake(0,-50) animated:YES];

in viewDidLoad

But if I set the content offset to 0,0 in viewDidLoad, I get something that looks like the second screen shot when the view loads.

This doesn't make much sense to me because if the content offset is 0,0 I would think the content should begin in the upper right corner of the screen.

Does anyone know what could be going on here?

Thanks!

+1  A: 

The contentOffset is the scroll position. Have you set the contentInsets? Otherwise, try moving the subviews of the UIScrollView down 50 pixels.

drawnonward
Yep, I'm pretty sure you want to set the `contentInsets` to a positive value instead.
Squeegy
Hmmm that actually did nothing. When I set the content height and it is much larger than the actual content, is there any automatic contentInset or vertical centering applied? Or is 0,0 the upper left corner of the screen when the view with the UIScrollView is loaded?
Tony
do you think it could be due to my layout in IB? it looks like this - http://tonyamoyal.com/stuff/ib_ss.png
Tony
What are the contentInset.top, contentOffset.y, bounds.origin.y and frame.origin.y of the scroll view when it looks right and wrong?
drawnonward
when it looks wrong, content inset top = 0.000000, content offset y = 0.000000, bounds origin y = 0.000000, frame origin y = 0.000000. but i can set the content inset top to 200 and it won't make a difference. when it looks right, I also get content inset top = 0.000000, content offset y = 0.000000, bounds origin y = 0.000000, frame origin y = 0.000000 but I set the content offset to (0,-50) ...very strange
Tony
Setting the contentInset will not change the look of position of the scroll, it just allows it to scroll farther in the given direction. If everything is zero whether it looks right or wrong, then something outside the scroll view is changing. Maybe the parent view of the scroll view is moving or something.
drawnonward