我正在尝试将数据从xib向上两个级别传递到VC,以便可以导航到单独的视图。我确实在IGListKit节中获取了数据,但是由于某些原因,passDataFromSectionUp
函数不会触发VC中的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;
}
xib
protocol UpdateDataDelegate: class {
func passUpdateData(data: String);
}
class CarouselControlCell: UICollectionViewCell {
weak var delegate: UpdateDataDelegate? = nil
@IBAction func addUpdate(_ sender: Any) {
delegate?.passUpdateData(data: "teeest");
}
答案 0 :(得分:0)
您的app.use(setDefaultResponse);
app.use(router)
类中的delegate: PassSectionDelegate
变量设置为nil,并且在您共享代码的情况下从未进行过更新。因此,在调用ExperiencesSectionController
时,delegate?.passDataFromSectionUp(sectionController: self)
变量将被标识为delegate
,随后将不执行任何操作。