简体   繁体   中英

How to know when a collection view outline has been expanded?

I am using an outline view style UICollectionView setup and setting up my header cells like so:

var content = cell.defaultContentConfiguration()
content.text = brand.name ?? "Unknown"
cell.contentConfiguration = content
  
let headerDisclosureOption = UICellAccessory.OutlineDisclosureOptions(style: .header)
cell.accessories = [.outlineDisclosure(options: headerDisclosureOption)]

However is it possible to receive something like a delegate call whenever a cell section is expanded? I would like to pull fresh data from the inte.net whenever a list is expanded.

Use the diffable data source's sectionSnapshotHandlers property. It is a SectionSnapshotHandlers instance, a struct consisting entirely of properties whose values are functions. Those functions, which you assign, are your callbacks.

See https://developer.apple.com/documentation/uikit/uicollectionviewdiffabledatasource/3600966-sectionsnapshothandlers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM