I have a paginated scrollview. In viewDidLoad, I check if the current orientation is terrain, then I set its content size to 440
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) { [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages,340)]; } else if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) { [scroll setFrame:CGRectMake(0,0,480,480)]; [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 440)]; }
everything works fine, scroll scrolls are smoothed and there is no diagonal scroll.
but when changing orientation
I need to set the scroll frame and content again, and I set it as shown below.
-(void)orientationChanged:(id)object { if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) { self.scroll.frame = [[UIScreen mainScreen]bounds]; [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 340)]; } else { self.scroll.frame = CGRectMake(0,0,480,480); [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 600)]; } }
I canβt understand why I have to set the height of the content size to 600 in landscape mode, and this is also not enough. and this adds another problem that scrollview starts to scroll diagonally, which I don't want, as it looks so weird. Can someone help me figure out where and what I don't see?
I set scrollview autoresist mask as
[scroll setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight];
but changing it does not help.