UIScrollView bounces on first touch

I have two UIScrollViews, one horizontal, one vertical, both two pages each (like horizontal - two pages wide, and vertical - two pages). Horizontal scrolling is vertical. I am trying to simulate a Calcbot design where you can scroll left / right buttons and up / down for a story.

However, when the image is loading, the horizontal scroll view is approximately 100 pixels higher than it should be. Then, when I touch him and start moving him a little, he jumps / moves to the correct position and stays there. How can I correctly display it from the very beginning?

Here is my code for viewDidLoad:

-(void)viewDidLoad {
horizontalScrollView.pagingEnabled = YES;
verticalScrollView.pagingEnabled = YES;


horizontalScrollView.contentSize = CGSizeMake(horizontalScrollView.bounds.size.width * 2, horizontalScrollView.bounds.size.height); // 2 pages wide.
verticalScrollView.contentSize = CGSizeMake(verticalScrollView.bounds.size.width, verticalScrollView.bounds.size.height * 2);


horizontalScrollView.delegate = self;
verticalScrollView.delegate = self;




[verticalScrollView addSubview:horizontalScrollView];

[verticalScrollView setContentOffset:CGPointMake(0, 640)];

[self.view addSubview:verticalScrollView];

horizontalScrollView.frame = CGRectMake(0, 540, 320, 460);

}

Thank.

+5
source share
3

UIScrollView , pagingEnabled = YES, contentOffset , ( bounds.size.height).

+4

, UIScrollView . -(void)viewWillAppear:(BOOL)animated. . , , , , viewWillAppear.

0

Move this line

horizontalScrollView.frame = CGRectMake(0, 540, 320, 460);

In viewWillAppearinstead viewDidLoad, see if it works

0
source

All Articles