我是iPhone
开发的新手。我需要创建一个应用程序,用户可以拍照,然后将其保存在iPhone上,我还必须使用SQLite
数据库来存储图像,然后再显示它。
任何人都可以帮我提供示例代码和程序说明吗?
编辑:我制作了一个使用UIImageView拍照的按钮,但我不确定它是否有效,因为我没有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;
}
以上代码使用前置摄像头
答案 0 :(得分:11)
您可以使用UIImagePickerController
课程拍照。
您可以使用以下方法捕获图像并存储它..
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
//put code for store image
}
答案 1 :(得分:4)