I'm subclassing UIScrollView and on the start I fill this ShowsScrollView with some items. After filling it, I setup frame and contentSize to this ShowsScrollView. Everything works fine for now, i get touches events, scrolling is working..
But after rotation to landscape, I change x and y coordinates of ShowsScrollView frame, to move it from bottom to top right corner. Then I resize it (change width and height of ShowsScrollView frame) and reorder items in this scroll. At the end I setup new contentSize. Now i get touches event only on first 1/4 of scrollview, scrolling also work only on 1/4 of scrollview, but scroll all items in scrollview. After all actions I write a log: NSLog(@"ViewController: setLandscape finished: size: %f, %f content: %f,%f",scrollView.frame.size.width,scrollView.frame.size.height, scrollView.contentSize.width, scrollView.contentSize.height );
Values are correct: ViewController: setLandscape finished: size: 390.000000, 723.000000 content: 390.000000,950.000000
On rotating back to portrait, I move and resize all thing back and everything works fine..
Please help!
I had the same issue and managed to get it working by setting the size of self.view again AFTER changing the scrollview's frame. I don't know why this works, but it does.
// Set the view's frame
if (UIDeviceOrientationIsLandscape(toOrientation)) {
[self.view setSize:CGSizeMake(1024, 724)];
} else {
[self.view setSize:CGSizeMake(768, 960)];
}
// Set scrollview frame
if (UIInterfaceOrientationIsLandscape(toOrientation)) {
self.scrollView.frame = CGRectMake(0, 0, 100, 300);
self.scrollView.contentSize = CGSizeMake(100, 600);
}
else {
self.scrollView.frame = CGRectMake(0, 0, 300, 100);
self.scrollView.contentSize = CGSizeMake(600, 100);
}
// Move your content around here
// Set the view's frame again
if (UIDeviceOrientationIsLandscape(toOrientation)) {
[self.view setSize:CGSizeMake(1024, 724)];
} else {
[self.view setSize:CGSizeMake(768, 960)];
}