簡體   English   中英

iPhone應用程序在橫向和縱向模式下都可以正常工作,但在iPad上只能在一種模式下工作?

[英]Iphone app is working fine in both landscape and portrait mode but in ipad it only works in one mode?

我通過使用自動旋轉方法制作了一個可以在iPhone上以橫向或縱向兩種模式正常工作的ios應用程序,我使用了以下代碼

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的新手。

需要檢查的一個地方是“應用程序”目標的“常規”選項卡上的“部署信息”部分。

在“部署目標”和“設備”選擇器的下方,您可以在iPhone和iPad之間切換,然后通過復選框啟用受支持的方向。

如果您已經為iPad和iPhone正確設置了這些設置,那么您可能想看看如何處理UIViewControllers的supportedInterfaceOrientationspreferredInterfaceOrientationForPresentation方法

首先看...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM