[FIXED] iOS Splashscreen not Centering Logo in Landscape mode

Issue

On a Mac, I designed the screen in a sample project using Xcode and copy the result into the splashscreen in VS2022 (Windows). The code works as expected running in Xcode. However, when running in VS2022, the screen display correctly in portrait mode but not in landscape. It appears this that the view isn’t aware that the device is in landscape mode. If you compare the images, you will see that the icon is positioned in landscape as if it was in portrait. See composite.

I have tried constraints to superview for both X and Y without success too.

So why does it work running on Mac/Xcode and not Windows/VS2022/Xamarin?

<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
    <device id="retina6_1" orientation="landscape" appearance="light"/>
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
        <capability name="System colors in document resources" minToolsVersion="11.0"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="tne-QT-ifu">
            <objects>
                <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
                    <view key="view" contentMode="scaleToFill" id="zO9-mi-WmR">
                        <rect key="frame" x="0.0" y="0.0" width="896" height="414"/>
                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                        <subviews>
                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="square.and.arrow.down.on.square.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="i2f-xz-yXe">
                                <rect key="frame" x="385.5" y="132.5" width="125" height="129"/>
                                <constraints>
                                    <constraint firstAttribute="width" constant="125" id="iSs-Y6-u1b"/>
                                    <constraint firstAttribute="height" constant="125" id="knT-iP-1d2"/>
                                </constraints>
                            </imageView>
                        </subviews>
                        <viewLayoutGuide key="safeArea" id="9TD-vu-rqU"/>
                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                        <constraints>
                            <constraint firstItem="i2f-xz-yXe" firstAttribute="centerY" secondItem="9TD-vu-rqU" secondAttribute="centerY" id="TIc-QI-zib"/>
                            <constraint firstItem="i2f-xz-yXe" firstAttribute="centerX" secondItem="9TD-vu-rqU" secondAttribute="centerX" id="cVF-vS-Ss8"/>
                        </constraints>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="131.25" y="95.652173913043484"/>
        </scene>
    </scenes>
    <resources>
        <image name="square.and.arrow.down.on.square.fill" catalog="system" width="122" height="128"/>
        <systemColor name="systemBackgroundColor">
            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
        </systemColor>
    </resources>
</document>

portrait landscape composite

Solution

Don’t trust the simulator, use an actual device.

Answered By – KTech

Answer Checked By – Katrina (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published