When I try to scroll down my UIScrollview, it returns to the same place where it was

Ok, so I use UIScrollView in my application. I placed scrollview in the viewcontroller in the bulletin board. I have several buttons and several shortcuts. But when I try to scroll down to the buttons below, scrollview just bounces back. This is the code I 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 
+6
source share
2 answers

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

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

  • In code using:

     scrollView.pagingEnabled = FALSE; 
+1
source

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

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

All Articles