ios - NSLayoutConstraint constant updates but doesn't animate like expected -


just prewarning - i’m pretty sure issue doesn’t have omission of self.view.layoutifneeded() in animation.

i’m expecting constraint ‘animatingsideconstraint’ animate value set in viewwillappear: new value set (and animated) in viewdidappear:, allows search bar appear grow extent of navigation bar.

the properties set, aren’t animated to.

here’s code:

@iboutlet var animatingsideconstraint: nslayoutconstraint!  override func viewdidload() {     super.viewdidload()      //  search bar     //     searchbar.delegate = self      if let searchbarcontainerbounds = navigationcontroller?.navigationbar.bounds     {         searchbarcontainerview.bounds = searchbarcontainerbounds     } }  override func viewwillappear(animated: bool) {     super.viewwillappear(animated)      //  search bar     //     //      set initial properties     //     animatingsideconstraint.constant = cgrectgetwidth(searchbarcontainerview.bounds) * 0.5      //      initialise use     //     searchbar.becomefirstresponder() }  override func viewdidappear(animated: bool) {     super.viewdidappear(animated)      //  search bar     //     uiview.animatewithduration(1.0, animations: { () -> void in         self.animatingsideconstraint.constant = 0          self.view.layoutifneeded()     }) } 

i’ve moved line self.animatingsideconstraint.constant = 0 before animation block too, unsurprisingly nothing.

any appreciated!

update:

override func viewdidappear(animated: bool) {     super.viewdidappear(animated)      //  search bar     //     self.animatingsideconstraint.constant = 400      nstimer.scheduledtimerwithtimeinterval(0.1, target: self, selector: "logdata", userinfo: nil, repeats: true)      uiview.animatewithduration(1.0, animations: { () -> void in         self.view.layoutifneeded()     }) }  func logdata() {     nslog("constant: %@", self.animatingsideconstraint.constant) } 

gives output:

2014-12-05 18:03:54.249 myapp[6483:2353740] unable simultaneously satisfy constraints.     @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints don't understand, refer documentation uiview property translatesautoresizingmaskintoconstraints)  (     "<nslayoutconstraint:0x174083cf0 h:[uisearchbar:0x12dd092c0]-(nsspace(0))-|   (names: '|':uiview:0x170182080 )>",     "<nslayoutconstraint:0x174083d40 h:|-(400)-[uisearchbar:0x12dd092c0]   (names: '|':uiview:0x170182080 )>",     "<nsautoresizingmasklayoutconstraint:0x1700856e0 h=--& v=--& h:[uiview:0x170182080(304)]>" )  attempt recover breaking constraint  <nslayoutconstraint:0x174083cf0 h:[uisearchbar:0x12dd092c0]-(nsspace(0))-|   (names: '|':uiview:0x170182080 )>  make symbolic breakpoint @ uiviewalertforunsatisfiableconstraints catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may helpful. 2014-12-05 18:03:54.361 myapp[6483:2353740] constant: 400 2014-12-05 18:03:54.455 myapp[6483:2353740] constant: 400 2014-12-05 18:03:54.556 myapp[6483:2353740] constant: 400 2014-12-05 18:03:54.655 myapp[6483:2353740] constant: 400 2014-12-05 18:03:54.755 myapp[6483:2353740] constant: 400 2014-12-05 18:03:54.856 myapp[6483:2353740] constant: 400 2014-12-05 18:03:54.955 myapp[6483:2353740] constant: 400 2014-12-05 18:03:55.056 myapp[6483:2353740] constant: 400 2014-12-05 18:03:55.155 myapp[6483:2353740] constant: 400 2014-12-05 18:03:55.255 myapp[6483:2353740] constant: 400 2014-12-05 18:03:55.355 myapp[6483:2353740] constant: 400 2014-12-05 18:03:55.455 myapp[6483:2353740] constant: 400 [repeated] 

update 2

here’s constraint in visual format, constraint i’m animating leading constraint.

starting properties:

|-(half search bar’s width)-[the search bar]-0-| 

end properties:

|-0-[the search bar]-0| 

mid properties halfway through animation, assuming simplicity search bar’s width 100

|-50-[the search bar]-0-| 

update 3:

note, leading constraint 1 referenced in iboutlet

enter image description here


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -