views:

54

answers:

1

I am trying to simulate the same behaviour as the defaults "Photos" application found on the iPhone OS 3.X-4.0. Basically when the user selects multiple photos in the Album via the UIImagePickerController from the Image Library,an icon (tick mark) appears on the image to represent that the image has been selected by the user. How to implement this functionality.

Many thanks

+1  A: 

create another UIImageView with the tickmark-image and add it as a subview to your selected UIImageView. Like this:

- (void)putCheckmarkOnImageView:(UIImageView *)anImageView {
    UIImageView *newIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkmark.png"]];
    newIV.tag = 42;
    CGPoint newIVPosition = CGPointMake(anImageView.bounds.size.width - newIV.bounds.size.width, 
                                        anImageView.bounds.size.height - newIV.bounds.size.height);
    CGRect newFrame = newIV.frame;
    newFrame.origin = newIVPosition;
    newIV.frame = newFrame;
    [anImageView addSubview:newIV];
    [newIV release];
}   

- (void)removeCheckmarkOnImageView:(UIImageView *)anImageView {
    [[anImageView viewWithTag:42] removeFromSuperview];
}
fluchtpunkt
Thanks fluchtpunkt - So the way the default "Photos" application works is, when the user clicks on an image in the album i.e. touchesBegan - we call putCheckmarkOnImageView on each of the images clicked. How do we then fetch a list of all selected images to lets say peform an operation like "Share" or "Delete" etc.
if the image is selected just add it to an NSMutableArray, which holds all selected images.
fluchtpunkt