Removing the image


#1

After completing the ch.13 challenge (clear the image of a possession) I now have a button next to the camera button like that :

Now with the thumbnails, I have to remove the thumbnail and thumbnailData, but without a key in order to identify them.

Do I have to use directly [possession setThumbnailDataFromImage:nil];

Also thumbnail is readonly, so I have to write a new private method in Possession.m in order to delete it also. Right?


#2

Here’s what I did. The “X” control is hooked up to my action method -clearImage: in ItemDetailViewController.m:

- (IBAction)clearImage:(id)sender {
    NSString *imageKey = [possession imageKey];
    if (imageKey) {
        [[ImageStore defaultImageStore] deleteImageForKey];
        [imageView setImage:nil];
        [possession setImageKey:nil];
        // Clear the thumbnail, too
        [possession setThumbnailDataFromImage:nil];
    }
}

In Possession.m, at the top of -setThumbnailDataFromImage:, I added:

    if (!image) {
        [self setThumbnail:nil];
        [self setThumbnailData:nil];
    }

#3

Thank you. I’ll try that out…


#4

Incidentally, just a thought…you might find the interface easier to use if you insert a Flexible Space Bar Button Item in between the buttons, to force the X control to the far right.


#5

Thanks… Nice touch!


#6

Could you explain to me how you posted the picture?
I tried this, but no luck.


#7

[quote=“macsicco”]Could you explain to me how you posted the picture?
I tried this, but no luck.
[/quote]

You have to first upload your local pic to an image host site. (like tinypic, imageshack etc) and THEN use the


#8

Ah, thanks.


#9

I had mine in the same place - next to it. With the button over to the right, it didn’t seem as obvious that it’s function was related to that of the camera button.