func showCustomViewController(vc : UIViewController,dummy : UIView,fromView1:UIViewController){
datePickerShown = true
let fromView = fromView1.navigationController?.view
var navTopConstraint : NSLayoutConstraint!
vc.view.translatesAutoresizingMaskIntoConstraints=false
self.navigationController?.addChildViewController(vc)
dummy.addSubview(vc.view)
vc.didMove(toParentViewController: self.navigationController)
dummy.addConstraint(NSLayoutConstraint(item: vc.view, attribute: .top, relatedBy: .equal, toItem: dummy, attribute: .top, multiplier: 1, constant: 0))
dummy.addConstraint(NSLayoutConstraint(item: vc.view, attribute: .left, relatedBy: .equal, toItem: dummy, attribute: .left, multiplier: 1, constant: 0))
dummy.addConstraint(NSLayoutConstraint(item: vc.view, attribute: .width, relatedBy: .equal, toItem: dummy, attribute: .width, multiplier: 1, constant: 0))
dummy.addConstraint(NSLayoutConstraint(item: vc.view, attribute: .height, relatedBy: .equal, toItem: dummy, attribute: .height, multiplier: 1, constant: 0))
dummy.backgroundColor=UIColor.clear
if dummy.superview == nil{
fromView?.addSubview(dummy)
}
for constraints in dummy.constraints{
if constraints.firstAttribute == .top{
navTopConstraint = constraints
}
}
fromView?.addConstraint(NSLayoutConstraint(item: dummy, attribute: .width, relatedBy: .equal, toItem: fromView, attribute: .width, multiplier: 1, constant:0 ))
fromView?.addConstraint(NSLayoutConstraint(item: dummy, attribute: .top, relatedBy: .equal, toItem: fromView, attribute: .top, multiplier: 1, constant: -60))
fromView?.addConstraint(NSLayoutConstraint(item: dummy, attribute: .bottom, relatedBy: .equal, toItem: fromView, attribute: .bottom, multiplier: 1, constant: 0))
fromView?.addConstraint(NSLayoutConstraint(item: dummy, attribute: .left, relatedBy: .equal, toItem: fromView, attribute: .left, multiplier: 1, constant: 0))
navTopConstraint.constant = (fromView?.frame.maxY)!
fromView?.layoutIfNeeded()
UIView.animate(withDuration: 0.33, delay: 0, options:.curveEaseInOut, animations: {
dummy.backgroundColor=UIColor.init(white: 0.0, alpha: 0.4)
navTopConstraint.constant=0
fromView?.layoutIfNeeded()
}, completion: nil)
}
dummy view is the uiview added to the current navigation controller view. vc is the viewcontroller to be added to the navigation controller view. In vc viewcontroller, viewdidload is called. But viewdidappear and viewwillappear is never called.why is it so? and how to call the same.Thanks in advance