Reputation:
In my app I am setting the image of a UIImageView
as follows:
override func viewWillAppear(animated: Bool) {
// ...
self.currentPlayer.image = UIImage(named: appDelegate.appSupportDirectory.stringByAppendingPathComponent(currentPlayer!.id!.UUIDString + ".jpg"))
}
In a different view, I allow the user to change the image, namely replace the file with a new one while keeping the name. When I return to this view the old picture is still shown. The app seems to remember the outdated picture even when I load a different player profile in between. How can I force the UIImageView
to refresh?
Upvotes: 0
Views: 1913
Reputation:
Solution found. Change the code to:
override func viewWillAppear(animated: Bool) {
// ...
self.currentPlayer.image = UIImage(contentsOfFile: appDelegate.appSupportDirectory.stringByAppendingPathComponent(currentPlayer!.id!.UUIDString + ".jpg"))
}
Upvotes: 1