I was able to use the answer andy_ gave.
I stored my offset to a CGFloat variable.
section.visibleItemsInvalidationHandler = { [weak self] (visibleItems, scrollOffset, environment) in
self?.currentScrollOffset = scrollOffset.x
}
I was then able to calculate the current cell being viewed by getting the cell width from the layout, taking into account insets, and calculating where the current scroll offset is. The index path I used was one known to exist, just for getting an accurate cell width.
let inset:CGFloat = 6
let indexPath = IndexPath(item: 0, section: 0)
if let attr = collectionView.layoutAttributesForItem(at: indexPath) {
let cellWidth = attr.bounds.width
let centerCell = cellWidth / 2
let result = Int((currentScrollOffset + centerCell) / (cellWidth + inset))
print("current index is \(result)")
}
Post
Replies
Boosts
Views
Activity
Apple collects the crash data, not your app. All apps on the App Store collect crash data, so I doubt Apple would leave it up to us to tick this checkbox (we would all have to). It must refer to collecting crash data from third party libraries in this case. We need clarity from Apple on this point though.
I can select a UICollectionView cell in Mac Catalyst. Local notifications also work. I'm running Big Sur, and maybe things have improved in a year.
Quitting Xcode and opening again.
Restarting the phone.
Cleaning the project from Project menu and selecting Clean Build Folder
Once I did all these things, it fixed the issue for me. Sometimes it's the simple things.
As far as I can see openAppWhenRun is static, and is read and opens the app even before perform() is run (if openAppWhenRun is true that is). In other words, openAppWhenRun can not be dynamic. Your variable myNumber is always false at the time the App Intent is run so that is why your app never opens.
It would be interesting to see where you set, and changed, the myNumber variable.