LoginSignup
0
0

More than 5 years have passed since last update.

NSLayoutConstraint.active は viewDidLoad の中で変更しても反映されない

Posted at

現象

掲題の通り、viewDidLoad の中で NSLayoutConstraint.active を変更しても view には反映されない。

対処法

とはいえ view の初期化時に条件に応じて変更したい場合もあるので、

dispatch_async(dispatch_get_main_queue()) { [weak self] in
    self?.hogeConstraint.active = false
}

のように次のRunLoopに委譲して、ライフサイクルの罠から逃がしてやる。(より良い解決法などあればコメントお願いします)

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0