I’m desperatly trying to find any solution for my UIScrollView issue, I know there were a lot of discussions in this forum but I couldn’t find any suitable solution.
My issue is that I only have labels and images, which are loaded from a database, in my scrollview. So I don’t know how long the labels are. My scrollview has i.e. a height of 615 (in interface builder), if I initialize this scrollview with this height, it won’t scroll.
So my question is how do I know what my height is, after I have loaded the text from my database? I also have a navigation bar and a tab bar in this ViewController if that does matter for the height?
The structure of my viewcontroller looks like this:
– NavigationController
– ViewController
– View
– ScrollView
– Label1
– Label2
– Label…
You need to take following small steps:
Set your scrollview size not more then size of screen (i.e (320, 480) till iPhone 4 and (320, 568) for iPhone5) like:
now set content size of your
scrollViewhere
heightOfAllSubViewsis cumulative height of all the labels and imageView, andheightOfVerticalSpacesis cumulative height of all vertical spaces between subviews. That’s it in my knowledge you’ll be good to go after doing this.