UIImagePickerControllerSourceTypesourceType=UIImagePicker
ControllerSourceTypeCamera;
if(![UIImagePickerControllerisSourceTypeAvailable:UIImagePick
erControllerSourceTypeCamera]) {
sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
}
UIImagePickerController * picker =
[[UIImagePickerControlleralloc]init];
picker.delegate =self;
picker.allowsEditing=YES;
picker.sourceType=sourceType;
[selfpresentModalViewController:picker
animated:YES];
-(void)imagePickerController:
(UIImagePickerController*)pickerdidFinishPickingMediaWith
Info:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
UIImage * image=[info
objectForKey:UIImagePickerControllerEditedImage];
[selfperformSelector:@selector(selectPic:)
withObject:imageafterDelay:0.1];
}
-(void)selectPic:(UIImage*)image
{
NSLog(@"image%@",image);
imageView = [[UIImageView alloc]
initWithImage:image];
imageView.frame = CGRectMake(0, 0,
image.size.width, image.size.height);
[self.viewaddSubview:imageView];
[selfperformSelectorInBackground:@selector(detect:)
withObject:nil];
}
detect为你自己的自定义方法