I am new in Swift and my code was working fine but I install Xcode 12.3 and since then child view data not showing. My code is like this
private func add(asChildViewController viewController: UIViewController) {
// Add Child View Controller
addChild(viewController)
let ScreenSize = UIScreen.main.bounds
// Add Child View as Subview
view.addSubview(viewController.view)
// Configure Child View
viewController.view.frame = CGRect(x: ScreenSize.width, y: viewController.view.frame.origin.y , width: viewController.view.frame.size.width, height: viewController.view.frame.size.height)
self.view.bringSubviewToFront(topView)
self.view.bringSubviewToFront(menuView)
self.view.bringSubviewToFront(view4Profile)
topView.layoutIfNeeded()
var containerFrame = view.bounds
if GlobalConstant.IS_IPHONE_X || GlobalConstant.IS_IPHONE_XSMAX
{
containerFrame.origin.y = 90
containerFrame.size.height = view.bounds.size.height - containerFrame.origin.y
}
else
{
containerFrame.origin.y = topView.frame.size.height
containerFrame.size.height = view.bounds.size.height - containerFrame.origin.y
}
viewController.view.frame = containerFrame
viewController.view.spruce.prepare(with: [.fadeIn, .expand(.slightly)])
viewController.view.spruce.animate([.fadeIn, .expand(.slightly)])
viewController.didMove(toParent: self)
}
public func remove(asChildViewController viewController: UIViewController) {
// Notify Child View Controller
viewController.willMove(toParent: nil)
// Remove Child View From Superview
viewController.view.removeFromSuperview()
// Notify Child View Controller
viewController.removeFromParent()
}
private lazy var ManagerDashboardTimeSheetViewController: ManagerDashboardTimeSheetViewController = {
// Load Storyboard
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
// Instantiate View Controller
var viewController = storyboard.instantiateViewController(withIdentifier: "ManagerDashboardTimeSheetViewController") as! ManagerDashboardTimeSheetViewController
// Add View Controller as Child View Controller
self.add(asChildViewController: viewController)
return viewController
}()
to call method
@objc func gotoManagerDashboardTimeSheetViewController()
{
view4Profile.isHidden = false
for controller in self.children
{
controller.view.removeFromSuperview()
controller.removeFromParent()
}
add(asChildViewController: ManagerDashboardTimeSheetViewController)
}
I was able to show Masterview as well as child view. But in Xcode 12.3 when I upload app it is showing blank screen. It's showing master view but not a child view.