古いバージョンのSwiftサンプルコードを持ってきて動かそうとしたときに、エラーとなったのとその対応方法
"options: nil"の記述がダメっぽい。
Nil is not compatible with expected argument type 'NSLayoutFormatOptions'
preferredView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[imageView]|",
options: nil, metrics: nil, views: ["imageView": imageView]))
preferredView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[imageView]|",
options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["imageView": imageView]))
- error Nil default argument value of cannot be converted to type ‘NSLayoutFormatOptions’
Attention Required! | Cloudflare
func addConstraints(format format: String, options: NSLayoutFormatOptions? = nil, metrics: [String: AnyObject]? = nil, views: [String: UIView])
func addConstraints(format format: String, options: NSLayoutFormatOptions, metrics: [String: AnyObject]? = nil, views: [String: UIView])
コメント