0

我是 iOS 新手,所以我遇到了这个问题:我在 UIViewController(父级)中编写了一个 UICollectionView,并以 UICollectionResuableView 作为标题。

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