Я пытаюсь создать TGMapView внутри моего UIView.Как только TMMapView создается, я получаю эту ошибку:
2019-02-04 14:47:22.288241-0500 IOSDemoApp[8325:289276] [LayoutConstraints] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x6000015f0b40 _UILayoutGuide:0x7fe52fc0e750.leading == TrimbleMaps.TMMapView:0x7fe52fc0e320.leading (inactive)>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:] to debug.
2019-02-04 14:47:22.288477-0500 IOSDemoApp[8325:289276] [LayoutConstraints] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x6000015f0c80 _UILayoutGuide:0x7fe52fc0e750.top == TrimbleMaps.TMMapView:0x7fe52fc0e320.top (inactive)>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:] to debug.
2019-02-04 14:47:22.288642-0500 IOSDemoApp[8325:289276] [LayoutConstraints] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x6000015f0e10 _UILayoutGuide:0x7fe52ff05670.leading == TrimbleMaps.TMMapView:0x7fe52fc0e320.leading (inactive)>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:] to debug.
2019-02-04 14:47:22.310967-0500 IOSDemoApp[8325:289276] [LayoutConstraints] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x6000015f0f00 TrimbleMaps.TMMapView:0x7fe52fc0e320.bottom == _UILayoutGuide:0x7fe52ff05670.bottom (inactive)>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:] to debug.
Кажется, не имеет значения, что UIView, который я пытаюсь создать здесь, является TGMapView.Если я пытаюсь создать простой старый UIView, я получаю ту же проблему.
public class Sample: UIView {
private var tangramMapView: TGMapView!
public var trivialView: UIView!
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// both have the same warning/error
guard let tangramMapView = TGMapView(coder: aDecoder) else { return nil }
trivialView = UIView.init(coder: aDecoder)
setup()
}
}
Когда я запускаю это, и TGMapView, и UIView отправляют одинаковые предупреждения (скопировано выше).Я ожидаю, что не будет никаких предупреждений и что ограничения UIViews обрабатываются в setup()
.Я добавляю подпредставления и устанавливаю ограничения в setup()
.
Есть ли что-то особенное в добавлении UIViews к UIViews, о котором я не знаю?Я сделал это в неправильном порядке?Разве это не может быть сделано до инициализации superView?
РЕДАКТИРОВАТЬ:
Почему вы инициализируете его с помощью aDecoder Sample views?
Нетидея.Я настроил его в раскадровке, и я установил вид в приложении с одним представлением как Sample
.В отладчике я вижу, что вызывается aDecoder
init.Я не могу сказать вам, почему другие нет.