I have been searching through stackOverflow and whatever google proposes but I wasn't able to get it to work. I am intending to draw a simple 2D Graph in a scrollview, the distance between my datapoints is kStepX
and I want the scrollview to be at least the width of the screen, if I have more datapoints it should scroll but no more than 100 points.
I think I have a problem with my Autolayout and sizing the contentWidth, so here is what I have done so far:
- I added a UIScrollView with the following constraints:
- Leading Space to Superview =0
- Top space to superview =0
- Height = width of superview
- Width = width of superview
- I then added a UIView (called GraphView) as a Child with the following constraints:
- zero space to all 4 bounds of scrollview
- center X and center Y to scrollview
in my GraphViewController I set the contenSize as:
historyScrollView.contentSize = CGSizeMake(MAX(SCREEN_WIDTH,sizeof(data)*kStepX), kGraphHeight);
but it does not scroll! if I set a fix width in the storyboard the scrollview scrolls further than I have data..
What am I doing wrong?