可以调用系统相机进行拍照和摄像,拍照后的图片可编辑,并保存到系统相册中。
#import "ViewController.h"
#import "ScanViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <Photos/Photos.h>
@interface ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property (nonatomic, strong) UIImageView *Image;
@end
@implementation ViewController
{
UIButton *scanBtn;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//创建按钮
[self creatControl];
}
- (void)creatControl {
//相机按钮
scanBtn = [UIButton buttonWithType:UIButtonTypeSystem];
scanBtn.frame = CGRectMake(100, 100, 100, 44);
[scanBtn setTitle:@"打开相机" forState:UIControlStateNormal];
[scanBtn addTarget:self action:@selector(scanBtnOnClick) forControlEvents:UIControlEventTouchUpInside];