Post

Replies

Boosts

Views

Activity

Reply to Widgets stopped working after building with Xcode 14
I did what was suggested here reducing the image and also compressing but doesn’t work on iOS 16 (iPhone 12 and iPad Air 4). Any other ideas ? Below the code used: extension WidgetContent { var image: Image? { guard let picData = self.pic, let uiImage = UIImage(data: picData) else { return nil } let targetWidth = uiImage.size.width let targetSize = CGSize(width: targetWidth, height: uiImage.size.height * targetWidth / uiImage.size.width) guard let resizedImage = uiImage.resized(toSize: targetSize) else { return nil } var compressionQuality: CGFloat = 0.7 var imageData = resizedImage.jpegData(compressionQuality: compressionQuality) while imageData?.count ?? 0 > 100 * 1024, compressionQuality > 0.1 { compressionQuality -= 0.1 imageData = resizedImage.jpegData(compressionQuality: compressionQuality) } guard let compressedImage = UIImage(data: imageData ?? Data()) else { return nil } return Image(uiImage: compressedImage) } }
Apr ’23