我的0 1 0 1 0 0 1 1
^ ^
| |
U/L I/G
遇到问题。有谁知道为什么该代码不起作用? ViewControllers
函数起作用...
A到B
print
从B到A
@IBaction func editButtonTapped(_ sender: Any) {
let imageCollectionView = self.storyboard?.instantiateViewController(withIdentifier: "ImageCollectionVC") as! ImageCollectionViewController
imageCollectionView.delegate = self
self.navigationController?.pushViewController(imageCollectionView,animated: true)
print("editButtonTapped")
}
}
extension ExampleViewController: ClassBDelegate {
func childVCDidComplete( with image: UIImage?) {
self.pickedImage = image!
}
}
那是我的完整项目:https://github.com/chriskonnerth/Wishlist
在我的情况下,ViewController A是 protocol ClassBDelegate {
func childVCDidComplete(with image: UIImage?)
}
class ImageCollectionViewController: UIViewController,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout{
@IBOutlet weak var imageCollectionView: UICollectionView!
var delegate: ClassBDelegate?
var tappedImage = UIImage()
func collectionView(_ collectionView: UICollectionView,didSelectItemAt indexPath: IndexPath) {
tappedImage = images[indexPath.row]
delegate?.childVCDidComplete(with: tappedImage)
navigationController?.popViewController(animated: true)
}
,B是ExampleViewController
UPDATE
那是我的情节提要:
ImageCollectionViewController
是右边的那个,ImageViewController
是左边的那个。