SCLAlertView-Swiftライブラリを使用して、TableViewのボタンをクリックするとポップアップが表示されるようにしようとしています。ポップアップライブラリを使用したときのビュー階層の相違
また、デバイスを回転させたときに寸法が正しいように制約を定義しようとしています。しかし、それは私に次のエラーを与える:
'UIViewLayoutMarginsGuide'.leading"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'
私はそのクラスからこのコードを呼び出しているので、私は、私はTableViewControllerからビューを取得しようとしているものと想定です。
let alert = SCLAlertView()
alert.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let margins = view.layoutMarginsGuide
alert.view.leadingAnchor.constraint(equalTo: margins.leadingAnchor).isActive = true
alert.view.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true
alert.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 8).isActive=true
alert.view.topAnchor.constraint(equalTo: view.topAnchor, constant: 8).isActive=true
alert.showInfo("Login", subTitle: "")
なぜ私は異なるビュー階層のアイテムを参照していますか?これを解決するために私は何ができますか?
ありがとうございます。
'TableViewController'ビューではなく' UIApplication.shared.keyWindow'ビューにフックしてみましたか? – dirtydanee