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;
}
}