Xamarin的故事板设计师使用保留的C#单词,阻止编译。

时间:2016-09-30 17:09:02

标签: c# ios xamarin.ios storyboard

如果我使用下载CloudKitAtlas演示版,并且我不修改故事板,那么我可以编译并执行该应用程序。

但是,如果我对导致设计器在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>

1 个答案:

答案 0 :(得分:0)

正如@ Abion47建议的那样,你不应该在插座名称中使用C#保留关键字。

在Xamarin Studio,XCode或普通编辑器中打开故事板,并将插座从delegate重命名为ContainerViewController(例如)。 Xamarin将重新生成.cs文件。

我理解您的困惑,因为在iOS世界(教程/文档)委托与C#中的含义不同,也不是保留关键字。