0

我正在尝试将数据从 xib 向上传递两个级别到 VC,以便我可以导航到单独的视图。我确实在 IGListKit 部分中获取了数据,但由于某种原因,passDataFromSectionUp函数不会触发print("like")VC 中的函数。

风险投资

class MainViewController: UIViewController, PassSectionDelegate {

func passDataFromSectionUp(sectionController: ExperiencesSectionController) {
    print("Like"); //Doesn't trigger
}

IGListKit 部分

protocol PassSectionDelegate: class {
  func passDataFromSectionUp(sectionController: ExperiencesSectionController);
}

class ExperiencesSectionController: ListSectionController, UpdateDataDelegate {

weak var delegate: PassSectionDelegate? = nil;

func passUpdateData(data: String) {
    print(data) //Data gets received
    delegate?.passDataFromSectionUp(sectionController: self);
}

...

if let cell = cell as? CarouselControlCell {
        cell.delegate = self;
    }

西布

protocol UpdateDataDelegate: class {
  func passUpdateData(data: String);
}

class CarouselControlCell: UICollectionViewCell {

weak var delegate: UpdateDataDelegate? = nil

@IBAction func addUpdate(_ sender: Any) {
    delegate?.passUpdateData(data: "teeest");
}
4

1 回答 1

0

您类中的delegate: PassSectionDelegate变量ExperiencesSectionController设置为 nil,并且由于您共享的代码从未更新过。当调用delegate?.passDataFromSectionUp(sectionController: self)时,delegate变量将被识别为nil,随后不会执行任何操作。

于 2018-09-22T09:36:09.963 回答