0
votes

I am using UIScrollview and set it's content size same as view's height.

I need to make my scrollview scrolls same in both side (Up / Down).

It will come back in same position I mean whenever we scrolls in top direction and leave scrolling it will come y = 20 pixels so when we scroll in bottom direction it will come back on the 20 pixels when we leave scrolling...

For setting scrollview content size

 CGSize scrollViewContentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
[self.scrollViewBg setContentSize:scrollViewContentSize];

Also I have tried to give content offset

 [scrollViewBg setContentOffset:CGPointMake(0, 0) animated:YES];

but not solved my problem.

1
Please check the height of your scroll view, it should be less that your content view height. For now, you can disable bouncing property of your scroll view to check if the content is scrollable or notKavyaKavita
Thanks Kavya KavitaChandni

1 Answers

0
votes

I just updated and make scrollview's height similar to view's height and increase it's content height like this and it solved my problem.

-(void)viewDidAppear:(BOOL)animated{

    float space = 2.5; // This is for making scroll view scrolls and on same positions from both sides.
    CGSize scrollViewContentSize = CGSizeMake(self.view.frame.size.width, 
    self.view.frame.size.height+space);
    [self.scrollViewBg setContentSize:scrollViewContentSize];
    [scrollViewBg setContentOffset:CGPointMake(0, 0) animated:YES];
}