I am using UIImageView
In my UIViewController
. In my case, I want to do if my image view changes then let me know if it was changed or not.
How i detect changes image in a UIImageView in Swift iOS
Asked Answered
Change means image in imageview changes? like you want to detect when image changes. –
Grisby
How is it going to change? and where do you need to detect that? Can you explain a bit about your goal? –
Assentation
Use KVO.
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
private var imageChangeObservation: NSKeyValueObservation?
override func viewDidLoad() {
super.viewDidLoad()
imageChangeObservation = imageView.observe(\.image, options: [.new]) { [weak self] (object, change) in
print("Image changed")
}
}
}
© 2022 - 2024 — McMap. All rights reserved.