Add call to activateConstraints on iOS8+ and fix build issues for OS X.

This commit is contained in:
Tadeas Kriz 2015-10-04 23:04:16 +02:00
parent ee34ec542f
commit 2afe4d47ec
2 changed files with 16 additions and 11 deletions

View File

@ -315,7 +315,11 @@ internal class ConcreteConstraint: Constraint {
}
// add constraints
installOnView!.addConstraints(newLayoutConstraints)
if #available(iOS 8.0, OSX 10.7, *) {
NSLayoutConstraint.activateConstraints(newLayoutConstraints)
} else {
installOnView!.addConstraints(newLayoutConstraints)
}
// set install info
self.installInfo = ConcreteConstraintInstallInfo(view: installOnView, layoutConstraints: NSHashTable.weakObjectsHashTable())
@ -337,9 +341,10 @@ internal class ConcreteConstraint: Constraint {
let installedLayoutConstraints = installInfo.layoutConstraints.allObjects as? [LayoutConstraint] {
if installedLayoutConstraints.count > 0 {
if let installedOnView = installInfo.view {
// remove the constraints from the UIView's storage
// remove the constraints from the UIView's storage
if #available(iOS 8, OSX 10.7, *) {
NSLayoutConstraint.deactivateConstraints(installedLayoutConstraints)
} else if let installedOnView = installInfo.view {
installedOnView.removeConstraints(installedLayoutConstraints)
}

View File

@ -95,7 +95,7 @@ public protocol ConstraintDescriptionRelatable: class {
func equalTo(other: View) -> ConstraintDescriptionEditable
@available(iOS 7.0, *)
func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable
@available(iOS 9.0, *)
@available(iOS 9.0, OSX 10.11, *)
func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
func equalTo(other: Float) -> ConstraintDescriptionEditable
func equalTo(other: Double) -> ConstraintDescriptionEditable
@ -110,7 +110,7 @@ public protocol ConstraintDescriptionRelatable: class {
func lessThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
@available(iOS 7.0, *)
func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
@available(iOS 9.0, *)
@available(iOS 9.0, OSX 10.11, *)
func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
@ -125,7 +125,7 @@ public protocol ConstraintDescriptionRelatable: class {
func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
@available(iOS 7.0, *)
func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
@available(iOS 9.0, *)
@available(iOS 9.0, OSX 10.11, *)
func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
@ -230,7 +230,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
internal func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
return self.constrainTo(other, relation: .Equal)
}
@available(iOS 9.0, *)
@available(iOS 9.0, OSX 10.11, *)
internal func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
return self.constrainTo(other, relation: .Equal)
}
@ -271,7 +271,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
internal func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
@available(iOS 9.0, *)
@available(iOS 9.0, OSX 10.11, *)
internal func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
@ -312,7 +312,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
internal func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
@available(iOS 9.0, *)
@available(iOS 9.0, OSX 10.11, *)
internal func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
@ -565,7 +565,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
}
@available(iOS 9.0, *)
@available(iOS 9.0, OSX 10.11, *)
private func constrainTo(other: NSLayoutAnchor, relation: ConstraintRelation) -> ConstraintDescription {
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
}