问题描述
我是 swift 新手,我的代码运行良好,但我安装了 Xcode 12.3,从那时起子视图数据没有显示。我的代码是这样的
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
}()
@objc func gotoManagerDashboardTimeSheetViewController()
{
view4Profile.isHidden = false
for controller in self.children
{
controller.view.removeFromSuperview()
controller.removeFromParent()
}
add(asChildViewController: ManagerDashboardTimeSheetViewController)
}
我能够显示主视图和子视图。但是在 xcode 12.3 中,当我上传应用程序时,它显示空白屏幕。它显示主视图而不是子视图。
任何身体都面临同样的问题。 请帮帮我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)