I have an app where the user can choose an image from the camera roll and than that image is loaded into an UIImageView
. However, if the image is big there is a delay till the selected image actually appears in the UIImageView
(Setting the image is not performed on the main thread
so the UI does not get frozen). Until the image is set, I would like to show an activity indicator which notifies the user that the app did not freeze, its just loading the image. However I don't know how to detect when the image got set in the UIImageView
to hide the activity indicator. I am guessing maybe KVO could help here, but I am not sure how to implement it properly.
Sorry for the noob question! :)
If you're using swift you can also create UIImageView
subclass and override image
property to observe the values with didSet
. Just remember to set the image of the superclass.
class ImageView: UIImageView {
override var image: UIImage? {
didSet {
super.image = image
println("Image Set")
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With