tylerwilson
04/17/2024, 5:28 PMWarning: ViewControllerBasedLifecycleOwner - 'ViewControllerBasedLifecycleOwner' received 'Action.DISPOSE' while in 'State.Running'. Make sure that view controller containment API is used correctly. 'removeFromParent' must be called before 'dispose'
I think I am doing all the right magic. For each ComposeViewController I embed as a Child VC and when the parent viewWillDisappear is called I call my method:
private func teardownView() {
child.willMove(toParent: nil)
child.view.snp.removeConstraints()
child.view.removeFromSuperview()
child.removeFromParent()
child = nil
}
But I still get the warning above. What might I be doing wrong? And perhaps there is an example somewhere?
I do notice leaks and my app cannot be used more than an hour or so before it runs out. Thanks!tylerwilson
04/17/2024, 5:28 PMprivate func setupView() {
child = Views_iosKt.ServiceSearchComposeViewController(viewModel: viewModel, clickable: false) { [weak self] action, service in
switch action {
case "staff":
self?.performStaffPicker()
break
default:
break
}
}
view.addSubview(child.view)
addChild(child)
child.didMove(toParent: self)
child.view.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(<http://view.safeAreaLayoutGuide.snp.top|view.safeAreaLayoutGuide.snp.top>)
make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom)
}
// child.view.backgroundColor = .red
}
tylerwilson
04/17/2024, 8:06 PM