-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kingfisher image elements untappable on iOS 18 #2295
Comments
The introduction of iOS 18 brought a new bug that made `KFAnimatedImage` not recognize tap gestures and become unclickable. (onevcat/Kingfisher#2295) This commit addresses the issue with a workaround found here: onevcat/Kingfisher#2046 (comment) The workaround was suggested by the author of the library to fix a slightly different issue, but that property seems to work for our purposes. The issue is addressed by adding a `contentShape` property to usages of `KFAnimatedImage`, in order to make them clickable. A custom modifier was created to make the solution less obscure and more obvious. Furthermore, one empty tap gesture handler was removed as it was preventing other tap gesture handlers on the image carousel from being triggered on iOS 18 Testing ------- PASS Configurations: - iPhone 13 mini on iOS 18.0 - iPhone SE simulator on iOS 17.5 Damus: This commit Coverage: - Check that the following views are clickable: - Images in the carousel - Profile picture on notes - Profile picture on thread comments - Profile picture on profile page Changelog-Fixed: Fix items that became unclickable on iOS 18 Closes: damus-io#2342 Closes: damus-io#2370 Signed-off-by: Daniel D’Aquino <[email protected]>
The introduction of iOS 18 brought a new bug that made `KFAnimatedImage` not recognize tap gestures and become unclickable. (onevcat/Kingfisher#2295) This commit addresses the issue with a workaround found here: onevcat/Kingfisher#2046 (comment) The workaround was suggested by the author of the library to fix a slightly different issue, but that property seems to work for our purposes. The issue is addressed by adding a `contentShape` property to usages of `KFAnimatedImage`, in order to make them clickable. A custom modifier was created to make the solution less obscure and more obvious. Furthermore, one empty tap gesture handler was removed as it was preventing other tap gesture handlers on the image carousel from being triggered on iOS 18 Testing ------- PASS Configurations: - iPhone 13 mini on iOS 18.0 - iPhone SE simulator on iOS 17.5 Damus: This commit Coverage: - Check that the following views are clickable: - Images in the carousel - Profile picture on notes - Profile picture on thread comments - Profile picture on profile page Changelog-Fixed: Fix items that became unclickable on iOS 18 Closes: damus-io#2342 Closes: damus-io#2370 Signed-off-by: Daniel D’Aquino <[email protected]>
Thanks for reporting this. It seems this issue is a regression in iOS 18, likely due to Apple rewriting some gesture-related code as they advertised. The simplest example to reproduce the problem is: struct ContentView: View {
@State private var count = 0
var body: some View {
VStack {
Text("Count: \(count)")
MyUIView()
.frame(width: 200, height: 200)
.onTapGesture { count += 1 }
}
.padding()
}
}
struct MyUIView: UIViewRepresentable {
func updateUIView(_ uiView: UIViewType, context: Context) { }
func makeUIView(context: Context) -> some UIView {
UIImageView(image: UIImage(systemName: "person.crop.circle"))
}
} To align the behavior with iOS 17 and earlier, the following adjustment is the simplest solution: func makeUIView(context: Context) -> some UIView {
- UIImageView(image: UIImage(systemName: "person.crop.circle"))
+ let v = UIImageView(image: UIImage(systemName: "person.crop.circle"))
+ v.isUserInteractionEnabled = true
+ return v
} The I can’t confirm if this is intended behavior by Apple, but given that As a workaround, I’ll apply this change to If the users wants a "click-through" behavior, they can apply a |
Fixed in 8.0.3. |
Thank you @onevcat! |
#3326) * Upgrade Kingfisher to fix a bug the prevented GIFs from being tapped. onevcat/Kingfisher#2295 * Fix tests.
Hello all. |
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Issue Description
There seems to be a regression on the tapping detection of Kingfisher image elements (We are using
KFAnimatedImage
) on SwiftUI caused by the introduction of iOS 18.What
We have found that
KFAnimatedImage
is no longer recognizingonTapGesture
on its own on iOS 18Reproduce
Device: Probably any iOS device (I used iPhone 13 mini and iPhone SE simulator)
iOS: 18.0 (I also used iOS 17.5 as a baseline)
Kingfisher: I am using 8.0.1 (Also reproducible on some 7.x versions)
Xcode: I am using Xcode 16.0 (16A242d)
I wrote a minimal example that reproduces the problem:
Here is the behavior, side-by-side, between running this on iOS 17.5 and iOS 18:
As shown in the videos above,
KFAnimatedImage
detectsonTapGesture
elements on iOS 17.5, but not on iOS 18.Other Comment
I found this comment on a separate issue: #2046 (comment)
and applying a similar patch as follows:
struct TapGestureExampleKFAnimatedImage: View { @State var tapCount = 0 let url = URL(string: "https://images.unsplash.com/photo-1722359945617-5cd0ea1a628f?q=80&w=1587&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D")! var body: some View { VStack { Text("KFAnimatedImage") .bold() KFAnimatedImage(url) .aspectRatio(contentMode: .fit) .frame(width: 200, height: 200) + .contentShape(Rectangle()) .onTapGesture { tapCount += 1 } Text("Tap count: \(tapCount)") } } }
does seem to solve the issue. However, I am concerned that this workaround is a bit counter-intuitive to use on every usage and may lead to hard-to-debug issues in the future. Is there a way we can fix this within
KFAnimatedImage
?The text was updated successfully, but these errors were encountered: