0
我做了一個iOS應用,其在兩個模式下工作正常,在iPhone要麼是橫向或縱向通過自轉方法我用下面的代碼iphone應用程序在橫向和縱向模式下都能正常工作,但在ipad中它只能在一種模式下工作?
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新手。
如果一切都被配置爲允許你在這些地方想要的方向,那麼你將不得不深入瞭解你如何處理旋轉,特別是使用willRotateToInterfaceOrientation:duration:和didRotateFromInterfaceOrientation:UIViewController的方法 –
是的,我選擇了通用但它不是在iPad上工作得很好。在iPhone中,它在兩種模式下都能正常工作,但在iPad中,它只能在一種模式下工作,當我旋轉iPad屏幕變成空白時 – user2591270
太棒了!所以現在我們知道你正確地支持所有的方向,當你旋轉時會發生什麼,而不是你想要的東西。那麼讓我們來看看你如何實現旋轉。你是否將視圖層次結構配置在筆尖,代碼或兩者中?你使用自動佈局嗎?請發表您的代碼,在代碼中任何設置,然後上傳您的willRotateToInterfaceOrientation代碼:期限:和didRotateFromInterfaceOrientation: –