首页 > 解决方案 > 为什么在iOS模拟器中实际启动屏幕出现之前会出现白屏

问题描述

我创建了一个颤振应用程序,然后使用情节提要添加了一个带有 XCode 的启动屏幕。我的启动屏幕包含一个与底部对齐的背景图像和一个居中的徽标。现在每次我启动应用程序时,在实际启动屏幕出现之前都会出现一个白屏。这是我的 LaunchScreen.storyboard:

<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
    <device id="retina6_1" orientation="portrait">
        <adaptation id="fullscreen"/>
    </device>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="EHf-IW-A2E">
            <objects>
                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
                        <viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleAspectFill" insetsLayoutMarginsFromSafeArea="NO" image="LaunchImage.Background" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
                                <rect key="frame" x="0.0" y="84" width="414" height="812"/>
                            </imageView>
                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchImage.Center" translatesAutoresizingMaskIntoConstraints="NO" id="m2E-Yf-1dK">
                                <rect key="frame" x="79" y="431" width="256" height="34"/>
                            </imageView>
                        </subviews>
                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                        <constraints>
                            <constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
                            <constraint firstItem="YRO-k0-Ey4" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="4X2-HB-R7a"/>
                            <constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="7gX-RD-p4w"/>
                            <constraint firstAttribute="trailing" secondItem="YRO-k0-Ey4" secondAttribute="trailing" id="SGD-Ee-rA9"/>
                            <constraint firstItem="m2E-Yf-1dK" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="Uz2-O6-cFf"/>
                            <constraint firstItem="m2E-Yf-1dK" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="f3e-ab-K73"/>
                        </constraints>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="76.811594202898561" y="251.11607142857142"/>
        </scene>
    </scenes>
    <resources>
        <image name="LaunchImage.Background" width="375" height="812"/>
        <image name="LaunchImage.Center" width="256" height="34"/>
    </resources>
</document>

我试图弄清楚为什么这个白屏会在实际启动屏幕之前显示,并且我尝试了其他 stackoverflow 问题中建议的许多事情,但无济于事。现在我没有头绪。

标签: iosxcodeflutterlaunch-screen

解决方案


我自己能够解决这个问题,结果证明是一个缓存问题。和

flutter clean

并擦除iOS模拟器上的设备设置和内容,白屏消失了。


推荐阅读