2
我最近將我的iPad應用程序轉換爲通用應用程序。我正在重新使用從我的IPad版本到iPhone版本的很多視圖。IOS通用應用程序旋轉
iPad需要支持所有的方向,有沒有辦法指定IPad版本以允許任何方向,但iPhone只允許肖像?
我最近將我的iPad應用程序轉換爲通用應用程序。我正在重新使用從我的IPad版本到iPhone版本的很多視圖。IOS通用應用程序旋轉
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;
}
}