从相册选取图片展示并实现自定义事件

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为你自己的自定义方法

以上是关于从相册选取图片展示并实现自定义事件的主要内容,如果未能解决你的问题,请参考以下文章

一款实用的viewer.js 图片相册

java 自定义事件的触发及监听

ActionHero js 和自定义 websocket 事件

iOS9中,swift判断相机,相册权限,选取图片为头像

js事件自定义dom事件自定义事件

vue创建自定义组件并监听原生事件