Hi. I'm having some trouble using scrollRectToVisible.
I have a quiz screen where the user can select an answer to a question. What I want to achieve is when the user gets the question right the scrollview should scroll to the next page.
I'm trying this:
Code:
// pageNumber is the current page
[scrollView scrollRectToVisbile:CGRectMake:(scrollView.frame.size.width * pageNumber + 1, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
I managed to use the exact above to animate the scrollView when a user touches a certain area of the screen but cannot for the life of me work out how to use it when a user clicks the correct button.
In my viewDidLoad I set scrollView.contentSize
Code:
// numPages is the total number of pages
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width * numPages, scrollView.frame.size.height)];
Yet, when I try and call scrollRectToVisible when the user taps the correct answer and log the contentSize.width to the console, the console says that my contentSize.width value is zero. However, when I log the contentSize in viewDidLoad, the console output is the value I want.
I don't set the contentSize of the scrollView anywhere else so I can't understand how the content size is getting reset to zero.
Any help you can give me is much appreciated and I apologise for what is quite a long post for something that is probably very simple. Thanks.