Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a way select a specific image for use in a UITable iOS?
    primarykey
    data
    text
    <p>I have a UITable, and I like to add an image in the detail view for a cell. I can handle the selection for any image from the camera roll or from the camera:</p> <pre><code>cell.imageView.image = someImage; </code></pre> <p>But how do I define a specific image - in the case above: "someImage", so that the next time the app is run, the correct image is shown for each item.</p> <p>UPDATE. This is the code I'm using to snap/select an image..</p> <pre><code>- (IBAction)btnTakePicture_Clicked:(id)sender { NSLog(@"%s", __FUNCTION__); UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Image Gallary", nil]; actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent; actionSheet.alpha=0.90; actionSheet.tag = 1; [actionSheet showInView:self.view]; } - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"%s", __FUNCTION__); switch (actionSheet.tag) { case 1: switch (buttonIndex) { case 0: { #if TARGET_IPHONE_SIMULATOR UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Ooops" message:@"Camera not available." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; #elif TARGET_OS_IPHONE UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.delegate = self; //picker.allowsEditing = YES; [self presentViewController:picker animated:YES completion:nil]; #endif } break; case 1: { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; picker.delegate = self; [self presentViewController:picker animated:YES completion:nil]; } break; } break; default: break; } } -(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info { NSLog(@"%s", __FUNCTION__); dataImage = UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],1); imgPicture.image = [[UIImage alloc] initWithData:dataImage]; [picker dismissViewControllerAnimated:YES completion:nil]; } </code></pre> <p>UPDATE 2. With the help from people below, I think this solution will work for me:</p> <pre><code>- (IBAction)photoLibraryAction:(id)sender { int c = self.capturedImages.count; for (int i=0; i &lt; c; i++ ){ if (self.imageView.tag == cellTag) { NSLog(@"found it"); } else { NSLog(@"can't find it"); } } } if ([self.capturedImages count] == 1) { // we took a single shot [self.imageView setImage:[self.capturedImages objectAtIndex:0]]; [self.imageView setTag:myTag]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload