6
votes

Okay, so i'm using a UIScrollView in my app. I have placed the scrollview in a viewcontroller in story board. I have several buttons there and a few labels. But when I try to scroll down to the buttons at the bottom, the scrollview just bounces back to the top. This is the code I have used:

In viewcontroller.h:

@interface ViewController : UIViewController{

    IBOutlet UIScrollView *hovscroll;
}
@end

In viewcontroller.m:

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [hovscroll setScrollEnabled:YES];
    [hovscroll setContentSize:CGSizeMake(320, 1500) ];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];

}

@end
2

2 Answers

1
votes

You need to disable paging. There are (at least) two ways of doing this:

  • In the storyboard, select the UIScrollView component, and un-tick "Paging Enabled" in the "Attributes Inspector."

  • In the code, by using:

    scrollView.pagingEnabled = FALSE;
    
-1
votes

You need to specify the size of the scrollable area by setting the contentSize property of your scroll view like this.

[scrollview setContentSize:CGSizeMake(320, 1000)];