addSubview 不识别 IBAction
addSubview dont recognize IBAction
我有一个视图控制器,在呈现之前呈现另一个视图控制器,带有 present:
(代码)
当我稍后尝试使用该子视图时遇到问题,因为我没有在子视图中找到按钮的 IBAction
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
}
我认为您在 addSubview
之前错过了 addChildViewController
查看。
vc.addChildViewController(vcEvent)
vc.viewDetail?.addSubview(vcEvent.view)
...
我有一个视图控制器,在呈现之前呈现另一个视图控制器,带有 present:
(代码)
当我稍后尝试使用该子视图时遇到问题,因为我没有在子视图中找到按钮的 IBAction
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
}
我认为您在 addSubview
之前错过了 addChildViewController
查看。
vc.addChildViewController(vcEvent)
vc.viewDetail?.addSubview(vcEvent.view)
...