- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最佳答案
我认为您不需要优先考虑约束。
我得到了这个结果:
使用这个 Storyboard:
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="pSd-1g-yzb">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Second-->
<scene sceneID="N6t-4u-rEI">
<objects>
<viewController id="pSd-1g-yzb" customClass="second" customModule="sdv" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="2V7-Hz-GBP"/>
<viewControllerLayoutGuide type="bottom" id="MEu-0g-Ng5"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="JAf-fN-bhN">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="106" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="RxB-gO-BaE">
<rect key="frame" x="0.0" y="104" width="375" height="563"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="106" id="ZS4-z5-fDX" customClass="cellTest" customModule="sdv" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="106"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ZS4-z5-fDX" id="Gzo-a3-xSX">
<rect key="frame" x="0.0" y="0.0" width="375" height="105.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="name:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KZg-iQ-1yZ">
<rect key="frame" x="8" y="15" width="47" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="QTh-E8-jrz"/>
<constraint firstAttribute="width" constant="47" id="pXL-H9-1Pi"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="John" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UDy-Br-8rJ">
<rect key="frame" x="63" y="15" width="107" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="A4A-fg-T3O"/>
<constraint firstAttribute="width" constant="107" id="clg-dt-kRd"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="City:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ofl-yu-07n">
<rect key="frame" x="8" y="44" width="35" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="byF-mE-EzO"/>
<constraint firstAttribute="height" constant="21" id="pEY-1J-Juf"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="HK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uvr-jw-AgS">
<rect key="frame" x="63" y="44" width="107" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="O8S-sI-SVg"/>
<constraint firstAttribute="width" constant="107" id="OKt-4D-irY"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="20" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OVW-yq-ra7">
<rect key="frame" x="296" y="15" width="38" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="38" id="Tve-KR-3qg"/>
<constraint firstAttribute="height" constant="21" id="XY5-8k-a8r"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Country:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sY6-0y-uY8">
<rect key="frame" x="222" y="44" width="66" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="66" id="FQ4-Du-Kg5"/>
<constraint firstAttribute="height" constant="21" id="f2H-DW-ZsP"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="HK" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yGP-I1-NoG">
<rect key="frame" x="296" y="44" width="38" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="pE3-ud-vJm"/>
<constraint firstAttribute="width" constant="38" id="vLT-EO-jKF"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Age:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uPL-7i-yNc">
<rect key="frame" x="253" y="15" width="35" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="mg8-e4-baN"/>
<constraint firstAttribute="height" constant="21" id="oTV-cD-jy1"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="KZg-iQ-1yZ" firstAttribute="top" secondItem="Gzo-a3-xSX" secondAttribute="topMargin" constant="7" id="30Z-xf-2jT"/>
<constraint firstItem="uvr-jw-AgS" firstAttribute="top" secondItem="UDy-Br-8rJ" secondAttribute="bottom" constant="8" id="3sf-vl-Ik6"/>
<constraint firstItem="Ofl-yu-07n" firstAttribute="leading" secondItem="Gzo-a3-xSX" secondAttribute="leadingMargin" id="Cq6-Rx-vkU"/>
<constraint firstAttribute="trailingMargin" secondItem="OVW-yq-ra7" secondAttribute="trailing" constant="33" id="DWV-l5-f18"/>
<constraint firstItem="Ofl-yu-07n" firstAttribute="top" secondItem="KZg-iQ-1yZ" secondAttribute="bottom" constant="8" id="KaQ-NN-tLo"/>
<constraint firstItem="yGP-I1-NoG" firstAttribute="leading" secondItem="sY6-0y-uY8" secondAttribute="trailing" constant="8" id="O2L-ng-7xA"/>
<constraint firstItem="UDy-Br-8rJ" firstAttribute="top" secondItem="Gzo-a3-xSX" secondAttribute="topMargin" constant="7" id="PVB-ck-Dlf"/>
<constraint firstAttribute="trailingMargin" secondItem="yGP-I1-NoG" secondAttribute="trailing" constant="33" id="RXc-0r-9rt"/>
<constraint firstItem="uvr-jw-AgS" firstAttribute="leading" secondItem="Ofl-yu-07n" secondAttribute="trailing" constant="20" id="ZQs-MN-PDV"/>
<constraint firstItem="KZg-iQ-1yZ" firstAttribute="leading" secondItem="Gzo-a3-xSX" secondAttribute="leadingMargin" id="ZZJ-gs-0Fs"/>
<constraint firstItem="yGP-I1-NoG" firstAttribute="top" secondItem="OVW-yq-ra7" secondAttribute="bottom" constant="8" id="f9a-58-K8F"/>
<constraint firstItem="sY6-0y-uY8" firstAttribute="top" secondItem="uPL-7i-yNc" secondAttribute="bottom" constant="8" id="hWN-Y2-3Ae"/>
<constraint firstItem="OVW-yq-ra7" firstAttribute="leading" secondItem="uPL-7i-yNc" secondAttribute="trailing" constant="8" id="mcM-m5-OXn"/>
<constraint firstItem="UDy-Br-8rJ" firstAttribute="leading" secondItem="KZg-iQ-1yZ" secondAttribute="trailing" constant="8" id="oOn-mC-oox"/>
<constraint firstItem="OVW-yq-ra7" firstAttribute="top" secondItem="Gzo-a3-xSX" secondAttribute="topMargin" constant="7" id="ycQ-u3-6lf"/>
<constraint firstItem="uPL-7i-yNc" firstAttribute="top" secondItem="Gzo-a3-xSX" secondAttribute="topMargin" constant="7" id="zbm-JK-27a"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="pSd-1g-yzb" id="tb8-8p-FL3"/>
<outlet property="delegate" destination="pSd-1g-yzb" id="plR-Bc-tN0"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="tableView" destination="RxB-gO-BaE" id="kTb-PN-Tpd"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="skk-yw-pih" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="493.60000000000002" y="74.212893553223395"/>
</scene>
</scenes>
</document>
您可以创建一个测试项目并将其粘贴到 Storyboard文件中。然后您将能够看到我是如何进行约束的。为此,请将其作为源代码打开:
为你的单元格创建一个类:
class cellTest: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}
并为您的委托(delegate) TableView 使用固定值:
class second: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentifier: String = "Cell"
let cell : cellTest = self.tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! cellTest
return cell
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
}
只需在您的 Storyboard中设置两个类,为您的 VC 和您的单元格,在属性检查器中设置 reuseIdentifier, TableView 数据源并委托(delegate)给您的 VC 并运行。
关于iOS tableview 单元格布局自动约束,每行 4 个标签,2 个在 2 边,2 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45965748/
我可以添加一个检查约束来确保所有值都是唯一的,但允许默认值重复吗? 最佳答案 您可以使用基于函数的索引 (FBI) 来实现此目的: create unique index idx on my_tabl
嗨,我在让我的约束在grails项目中工作时遇到了一些麻烦。我试图确保Site_ID的字段不留为空白,但仍接受空白输入。另外,我尝试设置字段显示的顺序,但即使尝试时也无法反射(reflect)在页面上
我似乎做错了,我正在尝试将一个字段修改为外键,并使用级联删除...我做错了什么? ALTER TABLE my_table ADD CONSTRAINT $4 FOREIGN KEY my_field
阅读目录 1、约束的基本概念 2、约束的案例实践 3、外键约束介绍 4、外键约束展示 5、删除
SQLite 约束 约束是在表的数据列上强制执行的规则。这些是用来限制可以插入到表中的数据类型。这确保了数据库中数据的准确性和可靠性。 约束可以是列级或表级。列级约束仅适用于列,表级约束被应用到整
我在 SerenityOS project 中偶然发现了这段代码: template void dbgln(CheckedFormatString&& fmtstr, const Parameters
我有表 tariffs,有两列:(tariff_id, reception) 我有表 users,有两列:(user_id, reception) 我的表 users_tariffs 有两列:(use
在 Derby 服务器中,如何使用模式的系统表中的信息来创建选择语句以检索每个表的约束名称? 最佳答案 相关手册是Derby Reference Manual .有许多可用版本:10.13 是 201
我正在使用 z3py 进行编码。请参阅以下示例。 from z3 import * x = Int('x') y = Int('y') s = Solver() s.add(x+y>3) if s.c
非常快速和简单的问题。我正在运行一个脚本来导入数据并声明了一个临时表并将检查约束应用于该表。显然,如果脚本运行不止一次,我会检查临时表是否已经存在,如果存在,我会删除并重新创建临时表。这也会删除并重新
我有一个浮点变量 x在一个线性程序中,它应该是 0或两个常量之间 CONSTANT_A和 CONSTANT_B : LP.addConstraint(x == 0 OR CONSTANT_A <= x
我在使用grails的spring-data-neo4j获得唯一约束时遇到了一些麻烦。 我怀疑这是因为我没有正确连接它,但是存储库正在扫描和连接,并且CRUD正在工作,所以我不确定我做错了什么。 我正
这个问题在这里已经有了答案: Is there a constraint that restricts my generic method to numeric types? (24 个回答) 7年前
我有一个浮点变量 x在一个线性程序中,它应该是 0或两个常量之间 CONSTANT_A和 CONSTANT_B : LP.addConstraint(x == 0 OR CONSTANT_A <= x
在iOS的 ScrollView 中将图像和带有动态文本(动态高度)的标签居中的最佳方法是什么? 我必须添加哪些约束?我真的无法弄清楚它是如何工作的,也许我无法处理它,因为我是一名 Android 开
考虑以下代码: class Foo f class Bar b newtype D d = D call :: Proxy c -> (forall a . c a => a -> Bool) ->
我有一个类型类,它强加了 KnownNat约束: class KnownNat (Card a) => HasFin a where type Card a :: Nat ... 而且,我有几
我知道REST原则上与HTTP无关。 HTTP是协议,REST是用于通过Web传输hypermedia的体系结构样式。 REST可以使用诸如HTTP,FTP等的任何应用程序层协议。关于REST的讨论很
我有这样的情况,我必须在数据库中存储复杂的数据编号。类似于 21/2011,其中 21 是文件编号,但 2011 是文件年份。所以我需要一些约束来处理唯一性,因为有编号为 21/2010 和 21/2
我有一个 MySql (InnoDb) 表,表示对许多类型的对象之一所做的评论。因为我正在使用 Concrete Table Inheritance ,对于下面显示的每种类型的对象(商店、类别、项目)
我是一名优秀的程序员,十分优秀!