iOS启动屏Logo横屏不居中:Xcode正常VS2022/Xamarin异常
启动屏布局在Xcode与Xamarin/VS2022中横屏表现不一致问题
我在Mac端通过Xcode创建示例工程设计启动屏界面,随后将代码复制到Windows端VS2022的Xamarin项目中作为启动屏使用。该代码在Xcode中运行表现符合预期,但在VS2022中,启动屏在竖屏模式下显示正常,横屏模式下Logo未居中,视图似乎未识别设备处于横屏状态,图标位置仍按照竖屏布局排列。我尝试设置Logo与父视图的X、Y轴约束也未解决该问题,请问为何该布局在Xcode和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>
相关截图
- 竖屏正常显示效果
- 横屏Logo未居中异常效果
- Xcode与VS2022表现对比图
内容的提问来源于stack exchange,提问作者KT-Guy
相关产品推荐
相关产品推荐

