以下のようなコードを書いています。
swift
1 2class LoginViewController: UIViewController { 3 private let emailTextField = UITextField() 4 5 let formWidth:CGFloat = 300 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 10 self.emailTextField.textColor = UIColor.black 11 self.emailTextField.placeholder = "Email" 12 self.emailTextField.frame.size = CGSize(width: formWidth, height: 30) 13 self.view.addSubview(emailTextField) 14 15 self.emailTextField.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 150).isActive = true 16 } 17 18 override func didReceiveMemoryWarning() { 19 super.didReceiveMemoryWarning() 20 } 21}
以下のコードを走らせると以下のようなエラーがでます。
2018-08-31 14:48:24.261045+0900 Apacheek[7087:7743309] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x600000281720 h=--& v=--& UITextField:0x7f999903c200.midY == 15 (active)>", "<NSAutoresizingMaskLayoutConstraint:0x600000281860 h=--& v=--& UITextField:0x7f999903c200.height == 30 (active)>", "<NSLayoutConstraint:0x60800028bc20 V:|-(150)-[UITextField:0x7f999903c200] (active, names: '|':UIView:0x7f9998c37d10 )>", "<NSAutoresizingMaskLayoutConstraint:0x6000002841a0 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' UIView:0x7f9998c37d10.minY == 0 (active, names: '|':UIWindow:0x7f999b615070 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60800028bc20 V:|-(150)-[UITextField:0x7f999903c200] (active, names: '|':UIView:0x7f9998c37d10 )>
これは何が原因なのでしょうか。
よろしくお願いいたします。
なぜコードに全角文字が混じっているのでしょうか?コードはコピペするようにして下さい。