Note that there are some explanatory texts on larger screens.

plurals
  1. POTake a photo and add to UITableView
    primarykey
    data
    text
    <p>I have an app that has a takePhoto <code>UIButton</code> on a <code>UIViewcontroller</code> that enables the user to take a photo by using the <code>imagePickerController</code>. I then want the photo to be placed in a <code>UITableView</code>.</p> <p>The photo part works and for testing purposes I have the image displayed in a <code>UIImage</code> <em>photoImageView.image</em> </p> <p>I have added the <code>UITableView</code> delegate and then <code>UITable</code> is called <em>photoTable</em> and the cell is called photoCell. I have tried to figure out the code below for adding the image to the table without success. Any help greatly appreciated.</p> <pre><code>- (IBAction)takePhoto:(id)sender { [self startCameraControllerFromViewController: self usingDelegate: self]; } -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image; image = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage]; photoImageView.image=image; UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); [picker dismissViewControllerAnimated:YES completion:nil]; } -(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker { [picker dismissViewControllerAnimated:YES completion:nil]; } - (BOOL) startCameraControllerFromViewController: (UIViewController*) controller usingDelegate: (id &lt;UIImagePickerControllerDelegate, UINavigationControllerDelegate&gt;) delegate { if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) return NO; UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; cameraUI.allowsEditing = NO; cameraUI.delegate = delegate; [controller presentViewController:cameraUI animated:YES completion:nil]; return YES; } - (UITableViewCell*)tableView:(UITableView*)photoTable cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString* CellIdentifier = @"photoCell"; UITableViewCell* cell = [photoTable dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) cell.imageView.image = [UIImage imageNamed:@"nameOfImage.jpg"]; return cell; } </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.
    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