从相册选取图片展示并实现自定义事件
Posted 华少不思议
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从相册选取图片展示并实现自定义事件相关的知识,希望对你有一定的参考价值。
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为你自己的自定义方法
以上是关于从相册选取图片展示并实现自定义事件的主要内容,如果未能解决你的问题,请参考以下文章