Reputation: 57
I have a view controller that presents another view controller, with present, before presenting it:
(code)
when I later try to use that subview I have problems because I do not find the IBAction of the buttons in the subview
DispatchQueue.main.async {
let vcEvent = UIStoryboard(name: "Detail", bundle: nil).instantiateViewController(withIdentifier: "eventDetail") as! EventDetailVC
vc.viewDetail?.addSubview(vcEvent.view)
vc.cover?.image = DataManager.shared.arrayImage[indexPath.row]
self.view.frame = (vc.viewDetail?.bounds)!
DataManager.shared.cover = DataManager.shared.arrayImage[indexPath.row]
//DataManager.shared.cover = DataManager.shared.arrayImage[indexPath.row]
}
present(vc, animated: true) {
//NOPE
}
Upvotes: 0
Views: 47
Reputation: 1177
I think you are missing addChildViewController
before addSubview
to view.
vc.addChildViewController(vcEvent)
vc.viewDetail?.addSubview(vcEvent.view)
...
Upvotes: 1