ipad开发从图片库中加载图片
来源:互联网 发布:三维矩阵旋转 编辑:程序博客网 时间:2024/05/28 16:07
在设计Ipad项目时从图片库中加载图片好处是用户可以通过数据线以及mac电脑上的itunes或预览程序 同步图片信息,这样可以方便图片的管理,应用程序从图片库获取图片,可以通过如下方法:
UIImagePickerController *ipc = [[UIImagePickerControlleralloc] init];
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //图片库的源
ipc.delegate = self; //代理为self 可见我们应该把用户pick的相关动作处理在当前类中实现,实现代理的协议UIImagePickerControllerDelegate
ipc.allowsImageEditing =NO; //禁止编辑
[selfpresentModalViewController:ipc animated:YES] ; //弹出模式对话框
之后就是对用户选取的处理了
@interface TestBedViewController :UIViewController <UINavigationControllerDelegate,UIImagePickerControllerDelegate>
@end
@implementation TestBedViewController
// 3.0-3.1 提供
- (void) setAllowsEditing:(BOOL)doesAllow forPicker:(UIImagePickerController *) ipc
{
SEL allowsSelector;
if ([ipc respondsToSelector:@selector(setAllowsEditing:)]) allowsSelector =@selector(setAllowsEditing:);
NSMethodSignature *ms = [ipc methodSignatureForSelector:allowsSelector];
NSInvocation *inv = [NSInvocationinvocationWithMethodSignature:ms];
[inv setTarget:ipc];
[inv setSelector:allowsSelector];
[inv setArgument:&doesAllow atIndex:2];
[inv invoke];
}
// 2.x 提供 当用户选取完成一副图片库中的图片保存到字典中
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
NSDictionary *dict = [NSDictionarydictionaryWithObject:image forKey:@"UIImagePickerControllerOriginalImage"];
[selfimagePickerController:picker didFinishPickingMediaWithInfo:dict];
}
// 如果用户取消
- (void) imagePickerControllerDidCancel:
(UIImagePickerController *)picker
{
[self dismissModalViewControllerAnimated:YES];
[picker release];
}
//从字典获取图片并显示到当前窗口,同时关闭模态窗口
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
SETIMAGE([info objectForKey:@"UIImagePickerControllerOriginalImage"]);
[self dismissModalViewControllerAnimated:YES];
[picker release];
}
- ipad开发从图片库中加载图片
- ipad开发从图片库中加载图片
- 从图片库中取得照片
- Android开发中从url中加载图片
- 加载字符图片(图片库Iconfont.CN)
- 从图片库选择图片并上传
- Ipad开发加载图片的几种方式
- CSDN Blog 缺陷通告之二--无法从图片库添加图片到文章中
- 从图片库中批量查找指定的图片并按自己的要求命名
- 从内存中加载图片
- 从流中加载图片
- ipad iphone 异步图片加载
- 保存图片到IPhone图片库中
- Unity Android/IOS 打开图片库和相机,并加载图片
- Glide图片库基本用法及加载认证的https图片
- LiveCode 第3天——从图片库取图片
- VC从文件中加载图片
- VC从文件中加载图片
- Parallel Query Fails with ORA-600 [15764] [ID 839536.1]
- 结构体大小
- Linux 2.6.19.x 内核编译配置选项简介
- flex加密与解密1
- Solaris vmstat
- ipad开发从图片库中加载图片
- Select函数实现原理分析
- 对标准函数库的理解
- package,source folder,folder 的区别和联系
- Android之SlidingDrawer滑动抽屉
- Android内核介绍
- Linux Socket编程(不限Linux)
- 在EditPlus中配置js和css格式化工具的操作
- STM32 使用通用计时器实现微秒延时