IOS如何通过点击图片响应内存的图片库
2014-04-21 14:21
337 查看
注意:开启图片点击事件:
在.h中,设置代理<UIImagePickerControllerDelegate>
eg:self.myImage.userInteractionEnabled=YES;//开启图片点击,
//创建单击手势
UITapGestureRecognizer *tap=[[UITapGestureRecognizer
alloc]initWithTarget:self
action:@selector(xt:)];
//给图片添加单击手势
[self.myImage
addGestureRecognizer:tap];
-(void) xt:(id)sender{
UIImagePickerController *img=[[UIImagePickerController
alloc]init];//图片加载
if ([UIImagePickerController
isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
img.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
img.delegate=self;
[self
presentViewController:img
animated:YES
completion:nil];//推出了图像选择视图
}
}
-(void)imagePickerController:(UIImagePickerController
*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *temp=[info
objectForKey:UIImagePickerControllerOriginalImage];
self.myImage.image=temp;
//收起视图
[picker dismissViewControllerAnimated:YES
completion:nil];
}
在.h中,设置代理<UIImagePickerControllerDelegate>
eg:self.myImage.userInteractionEnabled=YES;//开启图片点击,
//创建单击手势
UITapGestureRecognizer *tap=[[UITapGestureRecognizer
alloc]initWithTarget:self
action:@selector(xt:)];
//给图片添加单击手势
[self.myImage
addGestureRecognizer:tap];
-(void) xt:(id)sender{
UIImagePickerController *img=[[UIImagePickerController
alloc]init];//图片加载
if ([UIImagePickerController
isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
img.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
img.delegate=self;
[self
presentViewController:img
animated:YES
completion:nil];//推出了图像选择视图
}
}
-(void)imagePickerController:(UIImagePickerController
*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *temp=[info
objectForKey:UIImagePickerControllerOriginalImage];
self.myImage.image=temp;
//收起视图
[picker dismissViewControllerAnimated:YES
completion:nil];
}
相关文章推荐
- 进击的KFC:iOS WebView 如何通过js获取网页中所有图片并加入点击事件,实现浏览图片的功能
- iOS WebView 如何通过js获取网页中所有图片并加入点击事件,实现浏览图片的功能
- BS程序如何通过浏览器了解点击响应时间
- Gallery图片库获取到图片之后如何通过Uri获取到片图路径
- iOS如何给没有点击事件的View添加响应操作
- iOS开发工具-如何使用网络封包分析工具Charles,通过配置proxy对http、https、tcp、udp 等协议的请求响应过程交互信息进行分析、判断、解决我们移动开发中的遇到的各种实际问题。
- IOS UIView(UIButton)通过显示动画移动的时候 响应点击的解决方案
- ios 中通过图片的透明度来决定是否响应事件
- ios 增加对点击图片的响应
- iOS开发中通过点击按钮异步加载图片
- 如何通过文件流将很多图片存入SD卡,而不是自己内存
- ios通过按钮点击异步加载图片
- IOS开发教程 - 如何通过二进制数据上传图片
- iOS开发,图片太多占内存太大如何解决
- iOS中如何通过点击UITableViewCell中的Button来获取当前Cell的indexPath
- iOS开发之--如何修改TabBarItem的title的字体和颜色/BarButtonItem的title的字体大小和颜色/添加背景图片,并添加点击方法
- iOS开发-如何把广告,图片通过代码加到Screen上
- iOS WebView 获取内存图片 图片点击
- iOS图片验证码使用SDWeb实现的加载如何实现清理缓存点击刷新
- iOS开发:如何通过响应者链条获取到导航、标签等控制器呢?