Good morning, when using the following extension I'm getting a memory leak when using Instruments, I've tried capturing self with a weak reference but I still get the leak.
public extension UIImage {
func resize(_ targetSize: CGSize) -> UIImage {
let size = self.size
// Calculate the scaling ratios
let widthRatio = targetSize.width / size.width
let heightRatio = targetSize.height / size.height
// Determine the scale factor and size to fill the target size
let scaleFactor = max(widthRatio, heightRatio)
let scaledImageSize = CGSize(
width: size.width * scaleFactor,
height: size.height * scaleFactor
)
// Calculate the clipping rect
let clippingRect = CGRect(
x: (scaledImageSize.width - targetSize.width) / 2.0,
y: (scaledImageSize.height - targetSize.height) / 2.0,
width: targetSize.width,
height: targetSize.height
)
let format = UIGraphicsImageRendererFormat()
format.scale = 1
// Render the clipped image
let renderer = UIGraphicsImageRenderer(size: targetSize, format: format)
return autoreleasepool {
return renderer.image { _ in
self.draw(in: CGRect(
x: -clippingRect.origin.x,
y: -clippingRect.origin.y,
width: scaledImageSize.width,
height: scaledImageSize.height
))
}
}
}
}
Post
Replies
Boosts
Views
Activity
When using reloadInputViews() on a UITextView, if the keyboard is showing emojis it successfully resets to the default text view, but when the keyboard is showing numbers of special characters, it doesn't do anything. Do I have to implement a custom input view in order to achieve this ? I don't want it to resign and become first responder to make it work.
I can't execute individual tests or test suits on XCode 13.1, I get this message:
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
I can only execute the complete set of tests, is this a bug or am I missing something ?