-1

I am trying to get my view controller to scroll, but it won't work. Any clue to what's wrong?

    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,480)];
    scroll.contentSize = CGSizeMake(320, 480);
    [self.view addSubview:scroll];

    GGBoxView *boxee = [[GGBoxView alloc] initWithFrame:CGRectMake(12, 56, 144, 120)];
    [scroll addSubview:boxee];

This code is part of my GGViewController class.

GangstaGraham
  • 8,865
  • 12
  • 42
  • 60
  • exact duplicate of [this](http://stackoverflow.com/questions/2824435/uiscrollview-not-scrolling), [this](http://stackoverflow.com/questions/15612591/scrollview-not-moving) and [this one](http://stackoverflow.com/questions/5417414/uiscrollview-not-scrolling) too! – DD_ Mar 26 '13 at 06:31
  • Haha sorry i actually did not search fo app is not scorlling i saw some other questions like Add ScrollView to Existing ViewController but never found those other ones on Google. – GangstaGraham Mar 26 '13 at 06:37

2 Answers2

5

you are setting frame CGRectMake(0,0,320,480) and content size CGSizeMake(320, 480) which is equal, Content size must be greater then actual size of scrollView in order to exhibit scrolling.

Girish
  • 4,692
  • 4
  • 35
  • 55
abdus.me
  • 1,819
  • 22
  • 34
1

you are giving scrollview content size as 480 it means it takes entire screen, for scrolling the screen you have to give more content size then only it'l scrolls otherwise it won't scroll.

scroll.contentSize = CGSizeMake(320, 600);
Balu
  • 8,470
  • 2
  • 24
  • 41