我使用下面的代码从左向右移动。
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.rightNavController?.view.frame = CGRect(x: 0, y: 0, width: (appDelegate.window?.frame.size.width)!, height: (appDelegate.window?.frame.size.height)!)
self.removeNavigationController()
appDelegate.rightNavController = UINavigationController(rootViewController: leftmenuViewController)
appDelegate.rightNavController?.navigationBar.isHidden = true
baseController.addChildViewController(appDelegate.rightNavController!)
baseController.view.addSubview((appDelegate.rightNavController?.view)!)
UIView.animate(withDuration: 0.25, delay: 0.0, options: UIViewAnimationOptions(), animations: {
}, completion: { finished in
appDelegate.rightNavController?.view.frame = CGRect(x: 0, y: 0, width: 320, height: 568)
})
我在侧边菜单中的视图层次结构是UIView-> UiTableView。我在UIView上添加了点击手势以关闭侧边菜单。 以下是用于解雇的代码:(点击手势方法)
self.willMove(toParentViewController: nil)
UIView.animate(withDuration: 0.5, delay: 0.0, options: UIViewAnimationOptions(), animations: {
self.view.frame = CGRect(x:-self.view.frame.size.width, y: 0 ,width : self.view.frame.size.width, height :self.view.frame.size.height)
}, completion: { finished in
self.removeFromParentViewController()
self.view.removeFromSuperview()
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.rightNavController = nil
appDelegate.rightNavController?.view = nil
})
现在问题是当删除子viewController时,父视图控制器用户交互被禁用。
解决此问题的任何帮助。
答案 0 :(得分:0)
您要从问题的措辞中尝试实现的目标并不完全清楚,但我会在视图上查找导致您遇到麻烦的isUserInteractionEnabled属性。
另外,也许看看yourView.layer.zPosition。获得交互的视图是具有最高zPosition值的视图。每个人都默认为zPosition = 0.所有其他条件相同,添加的视图的顺序将决定谁获得事件。