Reputation: 646
I am new to iPhone
development. I need to make an App where the user can take a picture and then its saved on the iPhone and also I have to use SQLite
Database to store the image and later display it.
Can anyone help me with sample code and explanation of the procedure?
EDIT: I made a button that uses an UIImageView to take picture, but I'm not sure if it works because I don't have an iPhone:
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
imagePicker = nil;
newMedia = YES;
}
The above code uses the front camera
Upvotes: 1
Views: 20712
Reputation: 5886
you can use UIImagePickerController
class for take a picture..
you can use following methods for capture image and store it..
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
//put code for store image
}
Upvotes: 11
Reputation: 5267
You can use the examples available on apple's developer library
see these examples
and many more reference material is available too.
Happy Coding :)
Upvotes: 4