LoginSignup
6
6

More than 5 years have passed since last update.

Xcodeでxibを呼び出したときにオートレイアウトが効かなくて困った

Posted at

ハマったのでメモ
Xcodeでxibを呼び出すときにオートレイアウトが効かなくて困った。

ViewController
let addView = UINib(nibName: "addView", bundle: nil).instantiateWithOwner(self, options: nil)[0] as! UIView

みたいな感じで呼び出す。すると呼び出されたViewでオートレイアウトが効いておらず

非常に困った。freameの値を変えても変わらない
そこで

ViewController
addView.translatesAutoresizingMaskIntoConstraints = true

このコードを追加した。
その後frameの値を変えると問題なく反映。
無事に解決!
良かった良かった。

6
6
0

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
6
6