所以这几乎可以肯定是一个简单的答案,但我不能为我的生活解决它!
基本上,我希望我当前的应用程序只能纵向查看(至少现在是这样),并且可以以正确的方式向上或倒置。一切正常,当您在页面上旋转 iPad 时,一切正常,页面正常翻转。但是,如果您将 iPad 倒置(顶部的主页按钮)并单击一个按钮以加载新页面,则当页面加载时工具栏是不可见的!我不知道由于某种原因工具栏是否位于其余内容的后面,或者它是否不存在。如果您随后将 iPad 旋转回纵向,则会出现工具栏并且一切都恢复正常!
更奇怪的是,在 iPhone 上,当您使用倒置的 iPhone 加载页面时,工具栏就在那里!!
我已经尝试了各种 shouldAutorotateToInterfaceOrientation() 和 didRotateFromInterfaceOrientation() 方法,并根据方向调整 viewDidLoad 的大小/定位。但似乎没有任何工作!
这是我在 viewDidLoad() 方法中的代码:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
NSLog(@"iPhone");
if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait)
{
self.view.frame = CGRectMake(0, 0, 320, 460);
}
else if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortraitUpsideDown)
{
self.view.frame = CGRectMake(0, 20, 320, 460);
}
}
else
{
NSLog(@"iPad");
if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait)
{
self.view.frame = CGRectMake(0, 0, 768, 1024);
NSLog(@"iPad Portrait Up");
}
else if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortraitUpsideDown)
{
self.view.frame = CGRectMake(0, 20, 768, 1024);
NSLog(@"iPad Portrait Upside Down");
}
}
我在 didRotateFromInterfaceOrientation() 方法中尝试了类似的事情,但没有任何效果!
提前感谢您的任何帮助,并随时提出问题/请求更多代码
马特