collectionview와 viewcontroller 사이의주기 유지로 인해 viewcontroller를 파괴하는 데 문제가 있습니다. 나는 collectionview를 약한 변수로 만들려고했지만 viewcontroller에 collectionview를 추가하려고 할 때마다 아무것도 얻지 못하고있다. 콜렉션 뷰를 약하게 만드는 대신 다른 경로를 사용하려는 경우 그 경로도 개방적입니다.collectionview를 사용하여 유지주기를 없애는 방법
weak var table = UICollectionView(frame: CGRect(x: 0, y: 0, width: 0, height: 0), collectionViewLayout: UICollectionViewFlowLayout())
weak var customFlowLayout = UICollectionViewFlowLayout() //default cell spacing is 10
table?.frame = CGRect(x: 0, y: 50, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
table?.isHidden = true
table?.backgroundColor = UIColor.white
table?.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "customCellIdentifier")
table?.dataSource = self
table?.delegate = self
//table.rowHeight = CGFloat(100)
customFlowLayout?.minimumLineSpacing = 5 //default is 10
table?.collectionViewLayout = customFlowLayout!
self.view.addSubview(table!) //this is the line that breaks every time
어떻게 ViewController를 파괴하려고합니까? – atreat
컬렉션 뷰가 문제가 아니어야합니다. 문제는보기 컨트롤러에 직접 참조를 누른 다음보기 컨트롤러를 deinited 수 없습니다. 네가 어딘가에서 그걸 할거야. – Luzo