闪屏问题,Xcode中/ iOS 6中/的PhoneGap(Splash Screen issue,

2019-09-23 01:45发布

所以,我有我的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;
}

是的,我知道这是一个很大的代码,但我完全不确定的东西剪断,因为这个功能里面我不知道什么是错的究竟做。

从本质上讲,在横向模式下的iPad,但闪屏我的应用程序加载时旋转90度,并显示画像,而不是风景,然后闪回我的实际闪屏。 从看代码,我可以告诉大家,它的烧制设备检查的else语句,除此之外,我真的可以用你的球员在搞清楚什么改变,我需要做的帮助。

Answer 1:

设置setStatusBarOrientation只有横向模式,如果你只在你的应用程序横向模式下工作。

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];

要么

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];


Answer 2:

于是,我终于设法解决这项问题。 在CDVViewController.m在科尔多瓦的文件(你必须有2.0.0连得源)中,你必须注释掉行“showSplashScreen”功能startupImageTransform = CGAffineTransformMakeRotation(degreesToRadian(90)); 在所有的检查,如果因为该设备不旋转你,那么PhoneGap的尝试重新定位它。



文章来源: Splash Screen issue, Xcode/iOS 6/Phonegap