怎么获取相机里面的照片

1遵循协议:
UIImagePickerControllerDelegate,  UINavigationControllerDelegate
2、
- (void)openPhoto{
    //相机相册的控制器
    UIImagePickerController *pickerCotroller = [[UIImagePickerController alloc]init];
    //设置数据源类型(相册)
    pickerCotroller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    //设置代理
    pickerCotroller.delegate = self;
    //运行编辑
    pickerCotroller.allowsEditing = YES;
    [self presentViewController:pickerCotroller animated:YES completion:nil];
    
}

3、协议方法
#pragma mark UIImagePickerControllerDelegate协议方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    //找到图片
    UIImage *image = info[UIImagePickerControllerOriginalImage];
    //赋值
    self.homeImageView.image = image;/**< 更新button的背景图片 */
    [picker dismissViewControllerAnimated:YES completion:nil];
}
//点击取消按钮
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    
    [picker dismissViewControllerAnimated:YES completion:nil];
}


你可能感兴趣的:(怎么获取相机里面的照片)