I am getting crash for some iOS 15 devices like iPhone 12, 12 Mini & 13.
Here are the codes that I wrote to load child view controller
DispatchQueue.main.async {
self.addDetailVC()
}
}
private func addDetailVC(){
let childVC = AppStoryboard.Menu.viewController(viewControllerClass: RestaurantProductListViewController.self)
childVC.viewAnimationMode = .modal
childVC.viewModel = self.viewModel
self.addChild(childVC)
childVC.view.roundCorners([.topLeft, .topRight], radius: 20)
childVC.view.translatesAutoresizingMaskIntoConstraints = false
self.restaurantDetailsContainerView.addSubview(childVC.view)
NSLayoutConstraint.activate([
childVC.view.leadingAnchor.constraint(equalTo: restaurantDetailsContainerView.leadingAnchor),
childVC.view.trailingAnchor.constraint(equalTo: restaurantDetailsContainerView.trailingAnchor),
childVC.view.topAnchor.constraint(equalTo: restaurantDetailsContainerView.topAnchor),
childVC.view.bottomAnchor.constraint(equalTo: restaurantDetailsContainerView.bottomAnchor)
])
let org = childVC.view.frame.origin
childVC.view.frame.origin = CGPoint(x: childVC.view.frame.origin.x, y: self.restaurantDetailsContainerView.frame.height)
childVC.view.layoutIfNeeded()
UIView.animate(withDuration: 0.8, delay: 0, options: .transitionFlipFromBottom, animations: {
childVC.view.frame.origin = org
childVC.scrollDelegate = self
self.searchBarForDishes.delegate = childVC
childVC.updateUI()
}) { (finished) in
self.view.layoutIfNeeded()
childVC.didMove(toParent: self)
self.restaurantProductsChildVC = childVC
Cart.delegate = self.restaurantProductsChildVC
}
}
In Child View controller
func updateUI() {
self.loadDataAndUpdateUI()
}
private func loadDataAndUpdateUI(){
if let restaurantData = self.viewModel.restaurantDetails{
self.restaurantNameLabel.text = restaurantData.name
if let categories = restaurantData.categories, categories.count > 0 {
self.tableView.dataSource = self
}
}
}
Please find the attached crash report I got.
Anyone please help me in finding what is wrong with my code! Thank You!