How to use function NSLayoutConstraint.constraintsWithVisualFormat on Swift? -
i'm trying swift , using layout format. ide i'm using xcode6-beta2.
var viewdictionary:dictionary = ["mybutton": mybutton] var constraintformat1:anyobject[]! = nslayoutconstraint.constraintswithvisualformat("h:|-[mybutton]-|", options : nslayoutformatoptions(0), metrics: nil, views: viewdictionary) but got error message below.
*** terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'unable parse constraint format: unable interpret '|' character, because related view doesn't have superview h:|-[mybutton] ^' doesn't work on swift? or write wrong format pattern?
the "|" (vertical bar) character refers superview of view(s) you're declaring within of (directly or indirectly) in case "mybutton". when phone call .constraintswithvisualformat, tries implicitly find superview of button can create constraints between view , button. however, button has not yet been added view, fails.
swift
No comments:
Post a Comment