开发者

How to display images from the same place in Portrait and Landscape views

开发者 https://www.devze.com 2023-03-24 22:52 出处:网络
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.

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);
    }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消