How to display images from the same place in Portrait and Landscape views
In portrait mode, my app has a scrollview that shows 4 images in a 2x2 grid. In landscape mode the scrollview shows the images in a 3x1 grid.
I want to be able to rotate the view, and see the images from the position that they were in the previous orien开发者_开发百科tation.
I have tried to do this by setting the offset, but it doesn't work. Can anybody help me?
You need to resize the frame of that grid view in this method
- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation duration: (NSTimeInterval) duration {
UIInterfaceOrientation myInterface=self.Orientation;
if (myInterface == UIInterfaceOrientationLandscapeRight||myInterface == UIInterfaceOrientationLandscapeLeft) {
//landscape size of the gridView.frame=CGRectMake(0, 0, 480, 320);
}
else{
//portrait size of the gridView.frame=CGRectMake(0, 0, 320, 480);
}
}
精彩评论