[英]IOS Universal App Rotation
我最近將我的IPad應用程序轉換為通用應用程序。 我正在重復使用從我的IPad版本到IPhone版本的大量視圖。
IPad需要支持所有方向,有沒有辦法指定IPad版本允許任何方向,但IPhone只允許縱向?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && interfaceOrientation != UIInterfaceOrientationPortrait)
{
return NO;
}
else
{
return YES;
}
}
正如您可能猜到的,有一些替代方法可以獲得相同的結果。 以下內容可讓您為每個設備定義多個方向。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
else
{
return YES;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.