Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I try to scroll down on my UIScrollview, it bounces back to the same place it was

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
like image 468
Henrik LP Avatar asked Dec 15 '12 18:12

Henrik LP


1 Answers

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;
    
like image 125
Rok Strniša Avatar answered Nov 03 '22 20:11

Rok Strniša