我们有一个应用程序,这是唯一的横向,在所有的苹果设备上运行良好。它也有发射图像。我们被这个bug搞糊涂了。
我们已经在设备方向菜单中将应用设置为横向。所有视图仅在代码中定位。
在iPad2(iOS7)
ONLY上发生的情况是,当你在视图之间切换时,你会看到一秒钟的portrait
模式(这看起来很糟糕,因为图形只用于横向,所以图像在半屏幕上),然后在一秒钟后切换回横向模式。
在其他一些视图中,iPad2
由于某种原因永远停留在竖屏上,这意味着我们在半屏上看到图形,它的位置不是正确的。
我们得到的屏幕大小正好合适
float width=[UIScreen mainScreen].bounds.size.width;
float height=[UIScreen mainScreen].bounds.size.height;
768/1024
****使用storyboard制作的视图是可以的-其他使用软件制作的视图是不好的。
我使用以下代码(基于上面注释中给出的链接):
BOOL OSIsBelowIOS8 = [[[UIDevice currentDevice] systemVersion] floatValue] < 8.0;
if(OSIsBelowIOS8) {
if( [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ] )
{
self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] nativeBounds]];
}
else
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
}
} else {
self.window = [[UIWindow alloc] initWithFrame: [self screenBoundsOrientationDependent] ];
}
这里是screenBoundsOrientationDependent
//Always return the iOS8 way - i.e. height is the real orientation dependent height
- (CGRect)screenBoundsOrientationDependent {
UIScreen *screen = [UIScreen mainScreen];
CGRect screenRect;
if (![screen respondsToSelector:@selector(fixedCoordinateSpace)] && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
screenRect = CGRectMake(screen.bounds.origin.x, screen.bounds.origin.y, screen.bounds.size.height, screen.bounds.size.width);
} else {
screenRect = screen.bounds;
}
return screenRect;
}