views:

385

answers:

2

Hi!

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!

A: 

I'm having the very same issue... Did you solve it ?

Mauro Delrio
Nop, it looks like Simulators issue. Did you try on device? I don't have iPad yet, to try on it,..
miham
Please let me know, if you found sulution:)
miham
A: 

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)];
}
Squirtle
hmm, how did you setup autoresizing properties? Now i have default autoresizing (top and left), and in method didRotateFromInterfaceOrientation i have:[self.view setSize:CGSizeMake(768,1004)];scrollView.frame = CGRectMake(0, 584, 768, 420);// Calculate and setup content size for scrollView// Move content in scrollView[self.view setSize:CGSizeMake(768,1004)];1004 px height is because I have have tabbar on bottom, witch has 20 px heightSame result!I also try with disabling autoresizing and replacing setSize on view with setFrame with coordinates 0,0, but then i have big margin on top..
miham
I don't set autoresizing so I guess it's whatever the default value is. Can't think of anything else I set that might make a difference, hope you get it working!
Squirtle