【问题标题】:iPad2 is stay portrait for a second before move to landscapeiPad2 在切换到横向之前保持纵向一秒钟
【发布时间】:2015-08-24 13:48:58
【问题描述】:

我们有一个应用程序,它是唯一的横向应用程序,适用于所有苹果设备。 它也有发射图像。 我们被这个错误迷失了。

我们仅在设备方向菜单中将应用设置为横向。 所有视图都仅在代码中定位。

iPad2(iOS7) ONLY 上发生的情况是,当您在视图之间切换时,您会看到一秒钟 portrait 模式(这看起来很糟糕,因为图形仅用于横向,所以图像在半屏上)然后切换一秒钟后回到风景。

对于其他一些视图,iPad2 出于某种原因只能永远保持纵向 - 这意味着我们在半屏上看到图形。它的位置不正确。

我们得到的屏幕大小刚刚好

    float width=[UIScreen mainScreen].bounds.size.width;
        float height=[UIScreen mainScreen].bounds.size.height;
768/1024

用storyboard做的****视图还可以,其他用软件做的定位不好。

【问题讨论】:

标签: ios objective-c xcode ios7


【解决方案1】:

我使用以下代码(基于上述评论中给出的链接):

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    • 1970-01-01
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多