I\'m writing an iPhone app with Cocoa in xcode. I can\'t find any tutorials or sample code that shows how to take photos with the built in camera. How do I do this? Where can
Here is my code that i used to take picture for my app
- (IBAction)takephoto:(id)sender {
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completion:NULL];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
img = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[imageview setImage:img];
[self dismissViewControllerAnimated:YES completion:NULL];
}
if you want to retake picture just simple add this function
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:NULL];
}