IOS相机管理

名称:IOS相机管理

供应商:北京沃赢科技有限公司

价格:面议

最小起订量:1/件

地址:北京市海淀区银海大厦

手机:18201568921

联系人:刘老师 (请说在中科商务网上看到)

产品编号:78183752

更新时间:2021-02-03

发布者IP:123.120.35.46

详细说明

  我赢职场IOS相机管理教程:

  相机简介

  相机是移动设备的共同特点之一,我们能够使用相机拍摄图片,并在应用程序里调用它,而且相机的使用很简单。

  实例步骤

  1、创建一个简单的View based application

  2、在ViewController.xib中添加一个button (按钮),并为该按钮创建IBAction

  3、添加一个 image view (图像视图),并创建一个名为imageView的IBOutlet

  4、ViewController.h文件代码如下所示:

  #import

  @interface ViewController : UIViewController

  {

  UIImagePickerController *imagePicker;

  IBOutlet UIImageView *imageView;

  }

  - (IBAction)showCamera:(id)sender;

  @end

  5、修改ViewController.m,如下所示:

  #import "ViewController.h"

  @interface ViewController ()

  @end

  @implementation ViewController

  - (void)viewDidLoad

  {

  [super viewDidLoad];

  }

  - (void)didReceiveMemoryWarning

  {

  [super didReceiveMemoryWarning];

  // Dispose of any resources that can be recreated.

  }

  - (IBAction)showCamera:(id)sender {

  imagePicker.allowsEditing = YES;

  if ([UIImagePickerController isSourceTypeAvailable:

  UIImagePickerControllerSourceTypeCamera])

  {

  imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

  }

  else{

  imagePicker.sourceType =

  UIImagePickerControllerSourceTypePhotoLibrary;

  }

  [self presentModalViewController:imagePicker animated:YES];

  }

  -(void)imagePickerController:(UIImagePickerController *)picker

  didFinishPickingMediaWithInfo:(NSDictionary *)info{

  UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];

  if (image == nil) {

  image = [info objectForKey:UIImagePickerControllerOriginalImage];

  }

  imageView.image = image;

  }

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

  [self dismissModalViewControllerAnimated:YES];

  }

  @end

  学习链接: