简体   繁体   English

iOS 启动故事板中的许多 id 仅显示一个简单的居中图像的目的是什么?

[英]What's the purpose of many ids in an iOS launch storyboard that just displays a simple centered image?

I have this code for an iOS launch storyboard:我有一个 iOS 启动故事板的代码:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" 
          targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" 
          useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
    <device id="retina5_5" orientation="portrait" appearance="light"/>
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
        <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="Llm-lL-Icb"/>
                        <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
                        <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchIcon" translatesAutoresizingMaskIntoConstraints="NO" id="1864">
                                <rect key="frame" x="131" y="292" width="152" height="152"/>
                                <constraints>
                                    <constraint firstAttribute="width" constant="152" id="2074"/>
                                    <constraint firstAttribute="height" constant="152" id="2075"/>
                                </constraints>
                            </imageView>
                        </subviews>
                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                        <constraints>
                            <constraint firstItem="1864" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="2284"/>
                            <constraint firstAttribute="centerY" secondItem="1864" secondAttribute="centerY" id="2285"/>
                        </constraints>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="53" y="375"/>
        </scene>
    </scenes>
</document>

The code seems bloated, filled with IDs and possibly other things I do not need as all it does is display an image in the center.代码看起来很臃肿,充满了 ID 和其他可能我不需要的东西,因为它所做的只是在中心显示一个图像。

Can someone give me some suggestions on how I can clean up this code and what I could remove.有人可以就如何清理此代码以及可以删除的内容给我一些建议。

The Storyboard format is a human-readable format ( XML ) but it's not open. Storyboard 格式是一种人类可读的格式 ( XML ),但它不是开放的。 Unlike XAML , where you can define UI layout without having a designer, Storyboards have to be created with the Storyboard designer (shipped with Xcode ).XAML不同,您可以在没有设计器的情况下定义 UI 布局,故事板必须使用 Storyboard 设计器(随Xcode一起提供)创建。 I wouldn't recommend editing the Storyboard file manually in a text/xml editor because they will be overridden by the Storyboard designer once you open it.我不建议在 text/xml 编辑器中手动编辑 Storyboard 文件,因为一旦打开它们,Storyboard 设计器就会覆盖它们。

All the identifiers you see inside have an internal storyboard format defined by Apple and used by the Storyboard designer to link elements, containers, and constraints.你在里面看到的所有标识符都有一个由Apple定义的内部故事板格式,故事板设计者使用它来链接元素、容器和约束。

I agree that Storyboards introduce less flexibility and a lot of challenges in a multi-team-member environment because they are editable in the designer only:我同意 Storyboard 在多团队成员环境中引入较少的灵活性和很多挑战,因为它们只能在设计器中进行编辑:

  • one person can introduce changes at a time一个人可以一次引入变化
  • conflicts resolution冲突解决
  • change tracking变更追踪

Thus, from time to time you will see developers switching to code-only approach and define the UI in the source code only ( Objective-C or Swift ) by creating all the controls and layouts programmatically.因此,有时您会看到开发人员切换到code-only方法,并通过以编程方式创建所有控件和布局,仅在源代码( Objective-CSwift )中定义 UI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 启动带有居中图像 iOS 的屏幕情节提要 - Launch Screen Storyboard with centered image iOS IOS XIB 故事板启动屏幕文件显示内部图像的错误方向 - IOS XIB storyboard Launch Screen file displays wrong orientation of an image inside iOS启动图像没有故事板或图像 - iOS Launch Image without Storyboard or Images 在iOS应用程序中启动图像的目的是什么? - What is the purpose of launch images in an iOS application? 为 AppStore 的新 storyboard 要求更新具有 a.xib 启动屏幕的旧 iOS 应用程序的最简单方法是什么? - What's the easiest way to update an old iOS app with a .xib launch screen for the AppStore's new storyboard requirement? 启动屏幕故事板的图像消失 - Launch Screen Storyboard's Image Disappears 启动图像或启动xib / storyboard? - Launch image or launch xib / storyboard? Xamarin iOS启动屏幕图像在故事板中不从资产目录拉出 - Xamarin iOS Launch Screen Image In Storyboard Not Pulling From Asset Catalog 在 iOS LaunchScreen.storyboard 中放置图像会完全禁用启动屏幕 - Placing Image in iOS LaunchScreen.storyboard disables launch screen completely 如何在iOS的通用应用程序中定义启动屏幕故事板图像大小? - How to define launch screen storyboard image size in universal application in iOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM