Ala*_*an2 2 xcode ios uistoryboard xcode-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>
Run Code Online (Sandbox Code Playgroud)
代码看起来很臃肿,充满了 ID 和其他可能我不需要的东西,因为它所做的只是在中心显示一个图像。
有人可以就如何清理此代码以及可以删除的内容给我一些建议。
Storyboard 格式是一种人类可读的格式 ( XML),但它不是开放的。与XAML无需设计器即可定义 UI 布局的不同,必须使用 Storyboard 设计器(随 提供Xcode)创建故事板。我不建议在 text/xml 编辑器中手动编辑 Storyboard 文件,因为一旦打开它们,Storyboard 设计器就会覆盖它们。
您在里面看到的所有标识符都有一个内部故事板格式Apple,由故事板设计者定义并用于链接元素、容器和约束。
我同意 Storyboard 在多团队成员环境中引入较少的灵活性和很多挑战,因为它们只能在设计器中进行编辑:
因此,您不时会看到开发人员通过以编程方式创建所有控件和布局,转而code-only仅在源代码(Objective-C或Swift)中处理和定义 UI 。
| 归档时间: |
|
| 查看次数: |
239 次 |
| 最近记录: |