2011-08-04 47 views
0

在纵向模式下,我的应用程序具有滚动视图,该视图在2x2网格中显示4个图像。在横向模式下,滚动视图以3x1网格显示图像。如何在纵向和横向视图中显示来自相同位置的图像

我希望能够旋转视图,并从它们位于之前方向的位置查看图像。

我试图通过设置偏移量来做到这一点,但它不起作用。有谁能够帮助我?

回答

1

您需要调整的是网格视图的框架在此方法中

- (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

感谢Sanchit你的答案,但我已经通过这种方式尝试,但仍无法 –

相关问题