I have two UIScrollViews, one horizontal, one vertical, both two pages each (as in, the horizontal one is two pages wide, and the vertical one is two pages high). The horizontal scrollview is in the vertical one. I am trying to imitate Calcbot's design, where you can scroll left/right for buttons and up/down for history.
However, when the view loads, the horizontal scroll view is about 100 pixels higher than where it should be. Then, when I touch it and begin moving it a little, it jumps/skips down to the correct position and stays there. How do I have it appear correctly right from the start?
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);
}
Thanks.
Jumping in UIScrollView usually happens when you have set pagingEnabled = YES and the contentOffset is set to a position which is not on a page boundry (dividable by bounds.size.height).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With