【问题标题】:Xamarin for VS Table View cells not displaying label textXamarin for VS Table View 单元格不显示标签文本
【发布时间】:2016-08-02 21:48:19
【问题描述】:

我的故事板上的视图控制器中嵌入了一个表视图。表格视图中有 3 个表格视图单元格。每个单元格中都有一个文本字符:“A”、“B”和“C”。这些字符在 Visual Studio 的屏幕上可见,但是当我在模拟器中运行应用程序时,我什么也看不到。我已经仔细检查了表格/单元格是否已启用。下面的存储板 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>

【问题讨论】:

标签: c# xamarin-studio


【解决方案1】:

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

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

Static table view outside UITableViewController

【讨论】:

    猜你喜欢
    • 2014-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-26
    • 1970-01-01
    相关资源
    最近更新 更多