【发布时间】:2017-02-09 08:01:17
【问题描述】:
如果我使用下载CloudKitAtlas的demo,并且不修改storyboard,那么我可以编译并执行应用程序。
但是,如果我对故事板执行任何操作导致设计器在 C# 中生成,我会在我的 Designer.cs 中得到以下内容:
namespace CloudKitAtlas
{
[Register ("TableViewMainMenu")]
partial class TableViewMainMenu
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
CloudKitAtlas.MainMenuTableViewController dataSource { get; set; }
// ILLEGAL
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
CloudKitAtlas.MainMenuTableViewController delegate { get; set; }
void ReleaseDesignerOutlets ()
{
// ILLEGAL
if (dataSource != null) {
dataSource.Dispose ();
dataSource = null;
}
if (delegate != null) {
delegate.Dispose ();
delegate = null;
}
}
}
}
故事板源码是这样的:
<tableViewController id="pGg-6v-bdr" customClass="ContainerToDatabaseViewController" customModuleProvider="" sceneMemberID="viewController" hasRefreshControl="0" title="Cards">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="mLL-gJ-YKr">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="ExpenseCell" id="m0d-ak-lc9" rowHeight="56" customClass="ContainerToDatabaseViewCell">
<rect key="frame" x="0.0" y="22" width="414" height="56"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="m0d-ak-lc9" id="d3P-M7-ByW">
<rect key="frame" x="0.0" y="0.0" width="376" height="55.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Database1" lineBreakMode="tailTruncation" id="559" translatesAutoresizingMaskIntoConstraints="NO" minimumFontSize="9" adjustsLetterSpacingToFitWidth="NO" opaque="NO">
<rect key="frame" x="68" y="0.0" width="274" height="21"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
<nil key="highlightedColor"/>
<constraints>
<constraint id="588" firstAttribute="width" constant="274"/>
<constraint id="589" firstAttribute="height" constant="21"/>
</constraints>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Chris Lamont" lineBreakMode="tailTruncation" minimumFontSize="10" id="560" translatesAutoresizingMaskIntoConstraints="NO">
<rect key="frame" x="68" y="24" width="229" height="21"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="lightTextColor"/>
<nil key="highlightedColor"/>
<constraints>
<constraint id="578" firstAttribute="width" constant="229"/>
<constraint id="579" firstAttribute="height" constant="21"/>
</constraints>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="561" translatesAutoresizingMaskIntoConstraints="NO">
<rect key="frame" x="6" y="3" width="53" height="50"/>
<constraints>
<constraint id="569" firstAttribute="width" constant="53"/>
<constraint id="570" firstAttribute="height" constant="50"/>
</constraints>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" id="563" translatesAutoresizingMaskIntoConstraints="NO" misplaced="YES">
<rect key="frame" x="459" y="3" width="98" height="42"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" colorSpace="calibratedRGB" red="0.81176470588235294" green="0.81176470588235294" blue="0.81176470588235294" alpha="1"/>
<nil key="highlightedColor"/>
<constraints>
<constraint id="582" firstAttribute="height" constant="21"/>
</constraints>
</label>
</subviews>
<constraints>
<constraint id="567" firstItem="561" firstAttribute="leading" secondItem="d3P-M7-ByW" secondAttribute="leading" constant="6"/>
<constraint id="568" firstItem="d3P-M7-ByW" firstAttribute="bottom" secondItem="561" secondAttribute="bottom" constant="2"/>
<constraint id="576" firstItem="d3P-M7-ByW" firstAttribute="bottom" secondItem="560" secondAttribute="bottom" constant="10"/>
<constraint id="577" firstItem="560" firstAttribute="leading" secondItem="d3P-M7-ByW" secondAttribute="leading" constant="68"/>
<constraint id="580" firstItem="563" firstAttribute="top" secondItem="d3P-M7-ByW" secondAttribute="top" constant="3"/>
<constraint id="581" firstItem="d3P-M7-ByW" firstAttribute="trailing" secondItem="563" secondAttribute="trailing" constant="5"/>
<constraint id="586" firstItem="559" firstAttribute="top" secondItem="d3P-M7-ByW" secondAttribute="top"/>
<constraint id="587" firstItem="559" firstAttribute="leading" secondItem="d3P-M7-ByW" secondAttribute="leading" constant="68"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" colorSpace="calibratedRGB" red="0.34901960784313724" green="0.54117647058823526" blue="0.65490196078431373" alpha="1"/>
<connections>
<segue id="548" destination="Ah7-4n-0Wa" kind="show" identifier="showDetail"/>
<outlet property="CardTitle" destination="559" id="name-outlet-559"/>
<outlet property="CardSubtitle" destination="560" id="name-outlet-560"/>
<outlet property="CardImage" destination="561" id="name-outlet-561"/>
<outlet property="CardExtra" destination="563" id="name-outlet-563"/>
</connections>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="pGg-6v-bdr" id="P41-gY-KXY"/>
<outlet property="delegate" destination="pGg-6v-bdr" id="Y6K-Cp-Qkv"/>
</connections>
</tableView>
【问题讨论】:
-
如果您更改 XML 以使 outlet 标签的属性字段显示“delegate”以外的内容,会发生什么?
-
这里到底什么是非法的? Storyboard 和 Designer.cs 文件对我来说看起来很正常。
-
@AlexSorokoletov 以下是非法的,因为 Delegate 是保留字。
CloudKitAtlas.MainMenuTableViewController delegate -
我明白了,您在代码中的注释并不能准确说明问题所在。解决方案将按照 Abion47 的建议 - 使用其他名称作为出口。
-
@AlexSorokoletov Outlets 在 Xamarin.IOS 中被抽象化,目前尚不清楚如何使用 Visual Studio 或类似工具来完成此操作。
标签: c# ios xamarin.ios storyboard