问题
I took over a project using AngularJS, Ionic and Bootstrap to create hybrid apps for mobile devices.
Prior to upgrade to XCode 7 all went well. I updated my HTML-, CSS- and JS-code in editor, ran grunt run:ios
to create platform code and opened XCode. From there I built the .ipa-file without any issues (just with some warnings, which could be ignored).
However since using XCode 7 (needed for iOS 8- and iOS 9-devices), the splascreen will be shown incorrectly. Meaning: In Portrait mode.
Note #1: The splash-screen and the app have to be Landscape-only.
Note #2: When running grunt run:android
, all is well on the Android-based device.
Per 34919547 I updated the cordova-plugin-splashscreen plugin to version 3.1.0 as suggested herein. I also changed a reference, as the old version was hard-coded in a config-file.
Now first the splash-screen is shown by mistake in Portraid mode, then (after the defined timeout) in Landscape mode as it should. So things go a little bit better, but not by 100%.
How to get the splash-screen shown entirely in Landscape mode?
回答1:
Did you try cancelling out this line of code?
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(shouldAutorotate);
SEL swizzledSelector = @selector(splash_shouldAutorotate);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL didAddMethod = class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
}
Try cancel it out like this:
{
/*
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(shouldAutorotate);
SEL swizzledSelector = @selector(splash_shouldAutorotate);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL didAddMethod = class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
*/
}
You can find it in: cordova-plugin-splashscreen/src/ios/CDVViewController+SplashScreen.m
来源:https://stackoverflow.com/questions/34942234/splash-screen-rotation-not-woking-in-landscape-mode-on-ios-devices