|
Hi everybody I've been implementing the challenge for day 77 where we have to use the The To display the images, I use
While playing in the simulator I didn't find issues, but on a real iPhone I have many photos which are distorted. E.g. the aspect ratio is not respected/retained, even though I specified "scale to fit".
I have also tried to use I'm not sure which images are affected by this, because I do have a few portrait images which are shown in the correct aspect ratio... but then there are many others where the portrait is not respected and they end up distorted. Any idea what the source of the problem can be? |
|
I'm having the same problem, but only on images taken with my wife's iPhone 7; images taken with my iPhone XS do not have this issue. It doesn't matter where I use the images, when I open them in Instafilter or the day 77 challenge app on my phone or the simulator, I have the same problem. It's something about the images themselves. At first, I thought it was an issue with the HEIC format or something to do with HDR, but I disabled those settings on her phone and still have the issue. I made a trivial change (auto adjusted levels) to one of the images with preview, and it no longer had the issue. It's something about the way the iPhone 7 (iOS 13.4.1, same as my XS) is saving the images. |
|
OK, so I isolated the problem a little more and came up with a work-around.... Bug: This appears to be a SwiftUI bug with .aspectRatio(contentMode: .fit) and .scaledToFit() that only occurs A) with certain images (e.g. taken with an iPhone 7, etc) and B) when the problematic images are converted from a UIImage to a SwiftUI Image. When the same problematic images are read into a SwiftUI image directly from a file, the problem does not occur. Work-Around: Specify the size of the original UIImage as the aspect ratio for the SwiftUI image. E.g. given a UIImage named uiImage...
|
|
I had this issue on my iPhone 11 Pro... so it is not related to "old phones". I had the problem on various images. And today when I tested it again: I haven't found a single image with the problem !?! Is it possible that Apple fixed it now with an update? I also had crashes with the Probably fixed with the latest Xcode 11.4.1 |
|
I had the same issue on Xcode 11.6 and also 12.0 beta. I followed @cameter suggestion of using uiImage.size and it fixed the problem. Appreciated! |
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.