UIImagePickerController

UIImagePickerController 图片选取器

1.头文件中包含两个委托
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>


2.调出图片选取器
UIImagePickerController *ipController = [[UIImagePickerController alloc] init];
	[ipController setDelegate:self];
	[self presentModalViewController:ipController animated:YES];


3.重写委托方法
  点击指定图片委托该函数
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info


拓展
1.//判断设备是否是真机
  [[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location == NSNotFound)
2.设置读取图片的方法
[
ipController setSourceType:UIImagePickerControllerSourceTypeCamera];

UIImagePickerControllerSourceTypePhotoLibrary:表示显示所有的照片(默认)
UIImagePickerControllerSourceTypeCamera:表示从摄像头选取照片
UIImagePickerControllerSourceTypeSavedPhotosAlbum:表示仅仅从相册中选取照片。

你可能感兴趣的:(Objective-C)