I have 4 UIViewController namely vcA, vcB, vcC and vcD. Now, vcB has a tableView with two rows. And vcB is subViewed on vcA with one half side like iPad's setting screen. Till here, its working fine, but i required if I click on vcB's tableView's first cell, then vcC should be subViewed on other half side, similarly by selecting vcB's tableview's second cell vcD should be subViewed and vcC should remove.
Here is my screen:
Suppose u select "Select Country", the other vcC's view should subviewd & similary by selecting "Notification" vcD should be subViewed and vcC should remove. , and don't worry about frame, i will set that. And assume that the parent view is vcA here.
Here, I tried with delegate but on subViews delegate is not working I think, it can be Possible through NSNotificationCenter but is there any other way to do that ?
Thanks Any help will be appreciated.
Updated
Following way I'm using for get the result. But I know its not the correct way, and also not happening what i'm looking for.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(indexPath.section)
print(indexPath.row)
if UIDevice.Display.typeIsLike == UIDevice.DisplayType.ipad {
let iPadVc = iPadSettingViewController()
if indexPath.section == 0 && indexPath.row == 0 {
var sliderVC: SettingsViewController! = nil
sliderVC = self.storyboard?.instantiateViewController(withIdentifier: "SettingsViewController") as! SettingsViewController
sliderVC.view.frame = CGRect(x:0, y: 64, width: CGFloat((iPadVc.view.frame.size.width)/2.4), height: CGFloat(iPadVc.view.frame.size.height-64))
iPadVc.view?.addSubview(sliderVC.view)
}
else if indexPath.section == 0 && indexPath.row == 2 {
var countryVC : CountryViewController! = nil
countryVC = self.storyboard?.instantiateViewController(withIdentifier: "CountryViewController") as! CountryViewController
countryVC.view.frame = CGRect(x:CGFloat((iPadVc.view.frame.size.width)/2.4), y: 64, width: CGFloat((iPadVc.view.frame.size.width) - (iPadVc.view.frame.size.width)/2.4), height: CGFloat(iPadVc.view.frame.size.height-64))
iPadVc.view?.addSubview(countryVC.view)
}
}
}

You allocated 'iPadVc' and without presenting you are trying to add the
countryVCview.it's wrong. You just allocated the vc but the vcviewwill benilat the time of you are adding.My suggestion : Pass the
vcAobject reference tovcBwhile adding avcB.viewtovcA.view