Xamarin for VS Table View单元格不显示标签文本

时间:2016-08-02 21:48:19

标签: c# xamarin-studio

我在故事板上的View Controller中嵌入了一个Table View。表视图中有3个表视图单元格。每个单元格中都有一个文本字符:“A”,“B”和“C”。在Visual Studio中我的屏幕上可以看到这些字符,但是当我在模拟器中运行应用程序时,我什么也看不见。我已经仔细检查了表/单元格是否已启用。下面的Storeboard XML。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="tne-QT-ifu">
            <objects>
                <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
                        <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                        <subviews>
                            <containerView contentMode="scaleToFill" id="5" translatesAutoresizingMaskIntoConstraints="NO" fixedFrame="YES">
                                <rect key="frame" x="116" y="126" width="320" height="300"/>
                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                                <connections>
                                    <segue id="66" destination="13" kind="embed"/>
                                </connections>
                            </containerView>
                        </subviews>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="0.0" y="0.0"/>
        </scene>
        <scene sceneID="12">
            <objects>
                <tableViewController id="13" sceneMemberID="viewController">
                    <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="14">
                        <rect key="frame" x="0.0" y="0.0" width="320" height="300"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                        <prototypes>
                            <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="17" rowHeight="44">
                                <rect key="frame" x="0.0" y="22" width="320" height="44"/>
                                <autoresizingMask key="autoresizingMask"/>
                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="17" id="18">
                                    <rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
                                    <autoresizingMask key="autoresizingMask"/>
                                </tableViewCellContentView>
                            </tableViewCell>
                            <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="72" rowHeight="44" indentationLevel="0" style="IBUITableViewCellStyleDefault" textLabel="76">
                                <rect key="frame" x="0.0" y="66" width="320" height="44"/>
                                <autoresizingMask key="autoresizingMask"/>
                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="72" id="73">
                                    <rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
                                    <autoresizingMask key="autoresizingMask"/>
                                    <subviews>
                                        <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="A" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="76">
                                            <rect key="frame" x="16" y="0.0" width="288" height="43.5"/>
                                            <autoresizingMask key="autoresizingMask"/>
                                            <fontDescription key="fontDescription" type="system" pointSize="18"/>
                                            <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
                                            <nil key="highlightedColor"/>
                                        </label>
                                    </subviews>
                                </tableViewCellContentView>
                            </tableViewCell>
                            <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="77" rowHeight="44" style="IBUITableViewCellStyleDefault" textLabel="81">
                                <rect key="frame" x="0.0" y="110" width="320" height="44"/>
                                <autoresizingMask key="autoresizingMask"/>
                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="77" id="78">
                                    <rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
                                    <autoresizingMask key="autoresizingMask"/>
                                    <subviews>
                                        <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="B" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="81">
                                            <rect key="frame" x="16" y="0.0" width="288" height="43.5"/>
                                            <autoresizingMask key="autoresizingMask"/>
                                            <fontDescription key="fontDescription" type="system" pointSize="18"/>
                                            <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
                                            <nil key="highlightedColor"/>
                                        </label>
                                    </subviews>
                                </tableViewCellContentView>
                            </tableViewCell>
                            <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="79" rowHeight="44" style="IBUITableViewCellStyleDefault" textLabel="82">
                                <rect key="frame" x="0.0" y="154" width="320" height="44"/>
                                <autoresizingMask key="autoresizingMask"/>
                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="79" id="80">
                                    <rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
                                    <autoresizingMask key="autoresizingMask"/>
                                    <subviews>
                                        <label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="82" text="C">
                                            <rect key="frame" x="16" y="0.0" width="288" height="43.5"/>
                                            <autoresizingMask key="autoresizingMask"/>
                                            <fontDescription key="fontDescription" type="system" pointSize="18"/>
                                            <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
                                            <nil key="highlightedColor"/>
                                        </label>
                                    </subviews>
                                </tableViewCellContentView>
                            </tableViewCell>
                        </prototypes>
                        <connections>
                            <outlet property="dataSource" destination="13" id="15"/>
                            <outlet property="delegate" destination="13" id="16"/>
                        </connections>
                    </tableView>
                </tableViewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="19" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="646" y="-5"/>
        </scene>
    </scenes>
</document>

1 个答案:

答案 0 :(得分:0)

答案可以在下面的链接中找到。虽然该链接中的讨论是针对Xcode的,但解决方案是相同的。创建表视图控制器。将容器视图添加到View Controller并在其中嵌入表视图控制器。将表视图内容更改为“静态单元格”,然后添加一个部分。从那里你可以编辑你应该迈出一步的简单表,但不知何故花了5个!

Xamarin应该删除在属于非静态单元格内容表的单元格中添加文本的功能。这只是令人困惑。

Static table view outside UITableViewController

相关问题