0

在你给我任何反对票或评论之前。请阅读:

我是 ios 开发的新手,现在我正在使用这个应用程序。我已经使用 UIImagePickerController 完成了相机 Api。但是,我要做的是让用户存储他/她在手机中拍摄的照片,我将创建一个内部 SQLite3 数据库存储该图片在手机上的存储路径在数据库中(不是图片本身)然后将所有信息存储在数据库中。如果您能给我提供链接教程或任何指导,我将不胜感激。我已经在网上和堆栈溢出中检查过,我找不到我正在寻找的答案。

这是我的相机 API 代码:

ViewConroller.H

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIImagePickerControllerDelegate,         UIImagePickerControllerDelegate>
@property (retain, nonatomic) IBOutlet UIImageView *imageView;
@property (strong, nonatomic) IBOutlet UIButton *Camera;

-(IBAction)buttonPressed:(UIButton *)sender;
@end

视图控制器.M

 #import "ViewController.h"

 @interface ViewController ()

 @end

 @implementation ViewController

  - (void)viewDidLoad
  {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if (![UIImagePickerController     isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

    UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                          message:@"Device has no camera"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles: nil];

    [myAlertView show];

}


// Do any additional setup after loading the view, typically from a nib.
 }

 - (void)didReceiveMemoryWarning
 {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
 }
 - (IBAction)buttonPressed:(UIButton *)sender {

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

[self presentViewController:picker animated:YES completion:NULL];

  }
   - (void)imagePickerController:(UIImagePickerController *)picker    didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;

[picker dismissViewControllerAnimated:YES completion:NULL];

 }

 - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:NULL];

 }

  - (void)dealloc {
[_imageView release];
[super dealloc];
 }


 @end

我使用情节提要 Xcode 4.6.3 做到了

提前致谢

4

1 回答 1

0

使用核心数据。可以在这里找到一个很好的视频教程: https ://itunes.apple.com/us/course/coding-together-developing/id593208016

注意第 13 和 14 课。

于 2013-08-10T16:47:10.653 回答