Crash in iOS 15 and above for Some iPhone 12 mini, 12 and 13 Devices

222 Views Asked by At

Crashed: com.apple.main-thread EXC_BREAKPOINT 0x0000000104db0cf0 RestaurantDetailsParentViewController.addDetailVC() Crashlytics Screenshot

Here are the codes that I wrote to load child view controller

    func updateUI() {
    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
        }
    }
}

}

Here is the crash report I got.

Crashlog from device1 Crashlog from device Conti..

Anyone please help me in finding what is wrong with my code! Thank You!

0

There are 0 best solutions below