https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview
Post
Replies
Boosts
Views
Activity
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)
}
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
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
/// ...
}
}
}
https://stackoverflow.com/questions/78268523/how-do-i-resize-a-uicollectionviewlistcell-containing-a-uitextview.
https://stackoverflow.com/questions/78248735/cant-display-the-simplest-uitoolbar
https://stackoverflow.com/questions/78089692/swiftui-selectable-stepper-in-view-that-presents-modally
https://stackoverflow.com/questions/78241008/override-show-sender-of-uiviewcontroller-freezes-the-ui
Fixed: cell.accessories = [.disclosureIndicator(), .customView(configuration: .init(customView: UIStepper(), placement: .trailing(), reservedLayoutWidth: .actual))]
Okay thank you.
I don’t understand why the memory keeps growing, but I understand that I simply cannot use reloadRows(at:) in this case.
Answer: https://stackoverflow.com/questions/77939616/change-derived-data-location-in-xcode
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.