I am adding UIImageView
on a button click. I want to restore it using UIKit
.
I am getting restoration identifier in:
- (void)decodeRestorableStateWithCoder:(NSCoder *)coder;
How can I decode this UIImageView
?
i have used this code in one of my app.
here is the encoding & decoding process
-(void)encodeRestorableStateWithCoder:(NSCoder *)coder
{
NSData *imageData=UIImagePNGRepresentation(self.imgViewProfilePicture.image);
[coder encodeObject:imageData forKey:@"PROFILE_PICTURE"];
[super encodeRestorableStateWithCoder:coder];
}
-(void)decodeRestorableStateWithCoder:(NSCoder *)coder
{
self.imgViewProfilePicture.image=[UIImage imageWithData:[coder decodeObjectForKey:@"PROFILE_PICTURE"]];
[super decodeRestorableStateWithCoder:coder];
}