0

私はiOSが初めてなので、この問題に直面しています.UIViewController(親)にUICollectionResuableViewをヘッダーとしてUICollectionViewを書きました。

class ParentViewController: UIViewController, SideBarDelegate {

@IBOutlet weak var mPreviewsCollection: UICollectionView!

override func viewDidLoad() {
    ...
}
...
}

この UICollectionResuableView には、動的にカスタマイズされたタブを提供する別の UICollectionView (子) が含まれています (最善のアイデアではないかもしれませんが、意図したとおりに見えます)。

class ChildHeaderCollectionReusableView: UICollectionReusableView {

@IBOutlet var mTabHeader: UICollectionView!

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
}

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    ...
}
...

子のセルを選択するときに、親 UICollectionView (reloadData()) の内容を変更したいと思います。どうやってやるの?外部から親の実行中のインスタンスでメソッドを実行するにはどうすればよいですか? たとえばvar rootViewController = self.window!.rootViewController as KioskViewController、コンテンツがゼロの親 UIViewController の別のインスタンスを返します

4

0 に答える 0