Don't load a splash screen by default (flutter/engine#6883)
This commit is contained in:
@@ -88,7 +88,7 @@ FLUTTER_EXPORT
|
||||
*
|
||||
* @param asset The name of the asset. The name can be hierarchical.
|
||||
* @param package The name of the package from which the asset originates.
|
||||
* @returns: The file name to be used for lookup in the main bundle.
|
||||
* @return The file name to be used for lookup in the main bundle.
|
||||
*/
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
|
||||
|
||||
@@ -129,15 +129,19 @@ FLUTTER_EXPORT
|
||||
* a replacement until the first frame is rendered.
|
||||
*
|
||||
* The view used should be appropriate for multiple sizes; an autoresizing mask to
|
||||
* have a flexible
|
||||
* width and height will be applied automatically.
|
||||
*
|
||||
* If not specified, uses a view generated from `UILaunchStoryboardName` from the
|
||||
* main bundle's
|
||||
* `Info.plist` file.
|
||||
* have a flexible width and height will be applied automatically.
|
||||
*/
|
||||
@property(strong, nonatomic) UIView* splashScreenView;
|
||||
|
||||
/**
|
||||
* Attempts to set the `splashScreenView` property from the `UILaunchStoryboardName` from the
|
||||
* main bundle's `Info.plist` file. This method will not change the value of `splashScreenView`
|
||||
* if it cannot find a default one from a storyboard or nib.
|
||||
*
|
||||
* @return `YES` if successful, `NO` otherwise.
|
||||
*/
|
||||
- (BOOL)loadDefaultSplashScreenView;
|
||||
|
||||
/**
|
||||
* Controls whether the created view will be opaque or not.
|
||||
*
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
- (void)installSplashScreenViewIfNecessary {
|
||||
// Show the launch screen view again on top of the FlutterView if available.
|
||||
// This launch screen view will be removed once the first Flutter frame is rendered.
|
||||
if (self.isBeingPresented || self.isMovingToParentViewController) {
|
||||
if (_splashScreenView && (self.isBeingPresented || self.isMovingToParentViewController)) {
|
||||
[_splashScreenView.get() removeFromSuperview];
|
||||
_splashScreenView.reset();
|
||||
return;
|
||||
@@ -305,21 +305,29 @@
|
||||
}
|
||||
|
||||
- (UIView*)splashScreenView {
|
||||
if (_splashScreenView == nullptr) {
|
||||
NSString* launchscreenName =
|
||||
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UILaunchStoryboardName"];
|
||||
if (launchscreenName == nil) {
|
||||
return nil;
|
||||
}
|
||||
UIView* splashView = [self splashScreenFromStoryboard:launchscreenName];
|
||||
if (!splashView) {
|
||||
splashView = [self splashScreenFromXib:launchscreenName];
|
||||
}
|
||||
self.splashScreenView = splashView;
|
||||
if (!_splashScreenView) {
|
||||
return nil;
|
||||
}
|
||||
return _splashScreenView.get();
|
||||
}
|
||||
|
||||
- (BOOL)loadDefaultSplashScreenView {
|
||||
NSString* launchscreenName =
|
||||
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UILaunchStoryboardName"];
|
||||
if (launchscreenName == nil) {
|
||||
return NO;
|
||||
}
|
||||
UIView* splashView = [self splashScreenFromStoryboard:launchscreenName];
|
||||
if (!splashView) {
|
||||
splashView = [self splashScreenFromXib:launchscreenName];
|
||||
}
|
||||
if (!splashView) {
|
||||
return NO;
|
||||
}
|
||||
self.splashScreenView = splashView;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (UIView*)splashScreenFromStoryboard:(NSString*)name {
|
||||
UIStoryboard* storyboard = nil;
|
||||
@try {
|
||||
@@ -347,16 +355,10 @@
|
||||
if (!view) {
|
||||
// Special case: user wants to remove the splash screen view.
|
||||
[self removeSplashScreenViewIfPresent];
|
||||
} else if (_splashScreenView) {
|
||||
FML_LOG(ERROR) << "Attempt to set the FlutterViewController's splash screen multiple times was "
|
||||
"ignored. The FlutterViewController's splash screen can only be set once. "
|
||||
"This condition can occur if a running FlutterEngine instance has been "
|
||||
"passed into the FlutterViewController and a consumer later called "
|
||||
"[FlutterViewController setSplashScreen:]. Setting the splash screen on a "
|
||||
"FlutterViewController with an already running engine is not supported, as "
|
||||
"the rasterizer will already be running by the time the view is shown.";
|
||||
_splashScreenView.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
_splashScreenView.reset([view retain]);
|
||||
_splashScreenView.get().autoresizingMask =
|
||||
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
|
||||
Reference in New Issue
Block a user