启动画面问题,Xcode / iOS 6 / Phonegap [英] Splash Screen issue, Xcode/iOS 6/Phonegap

查看:75
本文介绍了启动画面问题,Xcode / iOS 6 / Phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在AppDelegate.m中具有以下功能:

So, I have this function in my AppDelegate.m:

- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{        
    [CDVLocalStorage __verifyAndFixDatabaseLocations];
    NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
    if (url && [url isKindOfClass:[NSURL class]]) {
        invokeString = [url absoluteString];
        NSLog(@"PHR launchOptions = %@", url);
    }
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    self.window = [[UIWindow alloc] initWithFrame:screenBounds];
    self.window.autoresizesSubviews = YES;
    self.detailViewController
    self.detailViewController = [[MainViewController alloc] init];
    self.detailViewController.useSplashScreen = YES;
    self.detailViewController.wwwFolderName = @"www";
    self.detailViewController.startPage = @"index.html";
    self.detailViewController.invokeString = invokeString;
    NSString *deviceType = [UIDevice currentDevice].model;

    if (![deviceType hasPrefix:@"iPad"] && ![deviceType hasPrefix:@"iPad Simulator"])
    {   
        CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];
        detailViewController.view.frame = viewBounds;

        BOOL forceStartupRotation = YES;
        UIDeviceOrientation curDevOrientation = [[UIDevice currentDevice] orientation];

        if (UIDeviceOrientationUnknown == curDevOrientation) {
            curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
        }

        if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) {
                if ([self.detailViewController supportsOrientation:curDevOrientation]) {
                    forceStartupRotation = NO;
                }
        } 

        if (forceStartupRotation) {
            UIInterfaceOrientation newOrient;
            if ([self.detailViewController supportsOrientation:UIInterfaceOrientationPortrait])
                newOrient = UIInterfaceOrientationPortrait;
            else if ([self.detailViewController supportsOrientation:UIInterfaceOrientationLandscapeLeft])
                newOrient = UIInterfaceOrientationLandscapeLeft;
            else if ([self.detailViewController supportsOrientation:UIInterfaceOrientationLandscapeRight])
                newOrient = UIInterfaceOrientationLandscapeRight;
             else
                newOrient = UIInterfaceOrientationPortraitUpsideDown;

            NSLog(@"AppDelegate forcing status bar to: %d from: %d", newOrient, curDevOrientation);
            [[UIApplication sharedApplication] setStatusBarOrientation:newOrient];
        }

        self.window.rootViewController = self.detailViewController;
    } else {
        NavViewController *leftViewController = [[NavViewController alloc] initWithNibName:@"NavViewController" bundle:nil];
        UINavigationController *leftNavViewController = [[UINavigationController alloc] initWithRootViewController:leftViewController];
        leftNavViewController.navigationBarHidden = YES;

        UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
        detailNavigationController.navigationBarHidden = YES;

        leftViewController.detailViewController = detailViewController;

        self.splitViewController = [[UISplitViewController alloc] init];
        self.splitViewController.viewControllers = [NSArray arrayWithObjects:leftNavViewController, detailNavigationController, nil];

        self.window.rootViewController = self.splitViewController;
        self.splitViewController.delegate = detailViewController;
        detailViewController.svc = self.splitViewController;
    }
    [self.window makeKeyAndVisible];

    return YES;
}

是的,我知道代码很多,但我不确定剪断什么内容,因为在此功能内部我不知道到底是什么错。

Yes, I know it's a lot of code, but I'm completely unsure of what to snip because inside of this function I don't know what's exactly wrong.

本质上,我的应用以横向模式加载到ipad上,但是启动屏幕旋转90度并显示肖像而不是风景,然后闪烁回到我的实际启动屏幕。通过查看代码,我可以判断出它是在设备检查的else语句中触发的,除了我可以真正利用你们的帮助来确定我需要进行哪些更改之外。

Essentially, my app loads on the ipad in landscape mode, but the splash screen rotates 90 degrees and shows portrait instead of landscape, then flashes back to my actual splash screen. From looking at the code, I can tell that it's firing in the else statement of the device check, other than that I could really use your guys' help in figuring out what changes I need to make.

推荐答案

所以,我终于设法解决了这个问题。在CDVViewController.m中的 showSplashScreen函数中的Cordova文件中(甚至必须有2.0.0才能获取源代码),您必须注释掉 startupImageTransform = CGAffineTransformMakeRotation(degreesToRadian(90))这一行。 ; 在所有if检查中,因为设备会为您进行轮换,所以phonegap会尝试对其进行重新定位。

So, I FINALLY managed to get this solved. In CDVViewController.m in the Cordova files (you have to have 2.0.0 to even get the sources) in the "showSplashScreen" function you have to comment out the line startupImageTransform = CGAffineTransformMakeRotation(degreesToRadian(90)); in all of the if checks, because the device does the rotation for you, then phonegap tries to re-orient it.

这篇关于启动画面问题,Xcode / iOS 6 / Phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆