Post

Replies

Boosts

Views

Activity

Reply to Lags in UICollectionView accessories when animatedly applying a snapshot unless .disclosureIndicator() is also an accessory
Make a custom cell: class SwitchCell: UICollectionViewListCell { let _switch = UISwitch() override init(frame: CGRect) { super.init(frame: frame) accessories = [ .customView(configuration: .init( customView: _switch, placement: .trailing()) ) ] } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } And edit cellRegistration accordingly: let cellRegistration = UICollectionView.CellRegistration<SwitchCell, String> { [weak self] cell, indexPath, itemIdentifier in guard let self else { return } cell._switch.isOn = bool cell._switch.addTarget(self, action: #selector(toggleBool), for: .valueChanged) }
Apr ’24
Reply to Update collection view supplementary view content
https://stackoverflow.com/questions/78311570/how-do-i-update-a-collection-view-supplementary-view-without-giving-up-on-animat At this time the answer is: To directly update a supplementaryView you need to know its kind and section. With your example, you could add a following didSet code to a footerText: var footerText = "Initial footer text" { didSet { guard let footer = collectionView.supplementaryView(forElementKind: UICollectionView.elementKindSectionFooter, at: IndexPath(row: 0, section: 0)) as? UICollectionViewListCell else { return } var contentConfiguration = UIListContentConfiguration.cell() contentConfiguration.text = self.footerText footer.contentConfiguration = contentConfiguration } } This way each time you change footerText, your footer will be updated. You could also move contentConfiguration update to a separate fuction, I've just copied it from your configureSupplementaryViewProvider
Apr ’24
Reply to Swift 5.10: Cannot access property '*' with a non-sendable type '*' from non-isolated deinit; this is an error in Swift 6
https://stackoverflow.com/questions/78284030/swift-5-10-cannot-access-property-with-a-non-sendable-type-from-non-iso/78285030#78285030 In a nutshell: call signInAnonymouslyIfNecessary() in viewDidDisappear(): avoid in general dealing with class deinitializers. But if you insist on calling signInAnonymouslyIfNecessary() in the deinitializer, you can: Mark AuthController as @MainActor Mark signInAnonymouslyIfNecessary as nonisolated Wrap signInAnonymouslyIfNecessary in a Task: @MainActor final class AuthController { nonisolated func signInAnonymouslyIfNecessary() { Task { @MainActor in /// ... } } }
Apr ’24
Reply to SwiftUI previews not loading
Thank you for responding despite my vagueness. Apple MacBook Air M1, 8 GB, MacOS Sonoma 14.2.1, Xcode 15.2--I forgot to paste it from the TSI message. After a few hours, I got the "Cannot preview in this file" error. I’ve noticed that my derived data folder has a different location according to Xcode and Finder. According to Xcode, the root path is /Users/filippo. But, according to Finder, it's /Users/Filippo. I changed my username a year ago. If you think this issue could be related to my problem, please tell me how to solve it.
Feb ’24