我使用自动旋转方法制作了一个 ios 应用程序,该应用程序在 iPhone 的两种模式下都可以正常工作,无论是横向还是纵向,我使用了以下代码
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view=Landscape;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (90));
self.view.bounds=CGRectMake(0.0,0.0,480.0,320.0);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view=Landscape;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (-90));
self.view.bounds=CGRectMake(0.0,0.0,480.0,320.0);
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
self.view=Portrait;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (0));
self.view.bounds=CGRectMake(0.0,0.0,320.0,480.0);
} else
{
self.view=Portrait;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (180));
self.view.bounds=CGRectMake(0.0,0.0,320.0,480.0);
}
}
但是对于 iPad,它只能在一种模式下工作,无论是横向还是纵向,当我旋转设备时它会显示空白的白色屏幕,但如果我不旋转它,它工作得很好。请指导我,因为我是 iOS 新手。