Skip to content

Commit 0aedb27

Browse files
committed
Apply workarounds for two Apple bugs
These are issues with Xcode 6b1 and the iOS 8 SDK first seed.
1 parent cd03ca7 commit 0aedb27

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

TableViewCellWithAutoLayout/TableViewController/TableViewCell.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import UIKit
99

1010
class TableViewCell: UITableViewCell
1111
{
12-
let labelHorizontalInsets = 15.0
13-
let labelVerticalInsets = 10.0
12+
let kLabelHorizontalInsets = 15.0
13+
let kLabelVerticalInsets = 10.0
1414

1515
var didSetupConstraints = false
1616

@@ -56,22 +56,27 @@ class TableViewCell: UITableViewCell
5656
// See here for further discussion: https://github.com/Alex311/TableCellWithAutoLayout/commit/bde387b27e33605eeac3465475d2f2ff9775f163#commitcomment-4633188
5757
// contentView.bounds = CGRect(x: 0.0, y: 0.0, width: 99999.0, height: 99999.0)
5858

59+
// Prevent the two UILabels from being compressed below their intrinsic content height
60+
// FIXME 7-Jun-14 Xcode 6b1: Apple Bug Report Radar #17220525: The UILayoutPriority enum is not compatible with Swift yet!
61+
// As a temporary workaround, we're using the raw value of UILayoutPriorityRequired = 1000
5962
UIView.autoSetPriority(1000) {
6063
self.titleLabel.autoSetContentCompressionResistancePriorityForAxis(.Vertical)
64+
self.bodyLabel.autoSetContentCompressionResistancePriorityForAxis(.Vertical)
6165
}
62-
titleLabel.autoPinEdgeToSuperviewEdge(.Top, withInset: labelVerticalInsets)
63-
titleLabel.autoPinEdgeToSuperviewEdge(.Leading, withInset: labelHorizontalInsets)
64-
titleLabel.autoPinEdgeToSuperviewEdge(.Trailing, withInset: labelHorizontalInsets)
66+
67+
// FIXME 7-Jun-14 Xcode 6b1: The Double literals below should refer to the defined constants kLabelHorizontalInsets and kLabelVerticalInsets.
68+
// However, there are currently intermittent compiler failures when the literals are replaced with these constants. For example, 'Could not find member .Top'
69+
70+
titleLabel.autoPinEdgeToSuperviewEdge(.Top, withInset: 10.0)
71+
titleLabel.autoPinEdgeToSuperviewEdge(.Leading, withInset: 15.0)
72+
titleLabel.autoPinEdgeToSuperviewEdge(.Trailing, withInset: 15.0)
6573

6674
// This constraint is an inequality so that if the cell is slightly taller than actually required, extra space will go here
67-
bodyLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: titleLabel, withOffset: labelVerticalInsets, relation: .GreaterThanOrEqual)
75+
bodyLabel.autoPinEdge(.Top, toEdge: .Bottom, ofView: titleLabel, withOffset: 10.0, relation: .GreaterThanOrEqual)
6876

69-
UIView.autoSetPriority(1000) {
70-
self.bodyLabel.autoSetContentCompressionResistancePriorityForAxis(.Vertical)
71-
}
72-
bodyLabel.autoPinEdgeToSuperviewEdge(.Leading, withInset: labelHorizontalInsets)
73-
bodyLabel.autoPinEdgeToSuperviewEdge(.Trailing, withInset: labelHorizontalInsets)
74-
bodyLabel.autoPinEdgeToSuperviewEdge(.Bottom, withInset: labelVerticalInsets)
77+
bodyLabel.autoPinEdgeToSuperviewEdge(.Leading, withInset: 15.0)
78+
bodyLabel.autoPinEdgeToSuperviewEdge(.Trailing, withInset: 15.0)
79+
bodyLabel.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 10.0)
7580

7681
didSetupConstraints = true
7782
}

0 commit comments

Comments
 (0)