So I've been stuck at the 2nd challenge in UIImagePickerController, i.e., doing a Fade in when an image is imported in InstaFilter app.
I have these two functions,
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
guard let image = info[.editedImage] as? UIImage else { return }
imageView.alpha = 0
dismiss(animated: true)
currentImage = image
print("S : \(Date())")
setupForProcessing()
}
func setupForProcessing() {
let beginImage = CIImage(image: currentImage)
currentFilter.setValue(beginImage, forKey: kCIInputImageKey)
applyProcessing()
UIView.animate(withDuration: 1 , delay: 0, options: [.layoutSubviews], animations: {
self.imageView.alpha = 1
// self.imageView.layoutIfNeeded()
}) { fin in
print("F : \(Date())")
}
}
And I added the two prints just to see who much time elasped between setting the alpha to 0 and then back to 1.
This is working fine when I import an image from Photo Library, but not when clicking a picture through camera. Case if point, here is the output when importing image with sourceType == .photoLibrary
S : 2021-08-01 05:11:36 +0000
F : 2021-08-01 05:11:37 +0000
And here's the output with .camera
S : 2021-08-01 05:11:23 +0000
F : 2021-08-01 05:11:23 +0000
I am at my wit's end, and either my google-fu is weaker than I think, or there just isn't much out there on this problem. Any help on this is greatly appreciated!
You can find the repo for this project here: https://github.com/AtinAgnihotri/FilterIt