UI 和图片相关的知识点
2015-12-25 17:22
417 查看
UIActionSheet的初始化方法
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"图片" delegate:self cancelButtonTitle:@"two" destructiveButtonTitle:@"从相册选取" otherButtonTitles:@"four", nil]; [action showInView:self.view];
UIImagePickerController(图片选择器) 1.初始化 2.设置代理人 3.允许编辑 allowsEditing 4.模态跳转 presentViewController ------>在action的点击事件里写
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ // NSLog(@"%ld", buttonIndex); UIImagePickerController *picker = [[UIImagePickerController alloc] init]; // 设置代理人 picker.delegate = self; // 允许编辑 picker.allowsEditing = YES; // 模态进行跳转 [self presentViewController:picker animated:YES completion:^{ }]; }
从本地选取图片 1.dismiss回第一页面 2.从字典里提取info里图片的内容------>imagePicker里写 ------>字典中的key有两个,两种不同的状态
// 从本地选取图片 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{ // [picker dismissViewControllerAnimated:YES completion:^{ }]; // NSLog(@"%@", info); // 从字典里提取info里的图片内容 UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; self.imageView.image = image; }
将图片存为本地 1.首先需要打开交互userInteractionEnabled 2.创建一个长按的手势 3.在长按的手势里,将图片保存在本地相册, 后面三个参数主要作为保存之后的信息回调,把保存的结果返回
self.imageView.userInteractionEnabled = YES; UILongPressGestureRecognizer *longpress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longpressAction:)]; [self.imageView addGestureRecognizer:longpress];
- (void)longpressAction:(UILongPressGestureRecognizer *)longpress{ // 把图片保存到本地相册 // 后面三个参数主要是作为保存之后的信息回调,把保存的结果返回 UIImageWriteToSavedPhotosAlbum(self.imageView.image, nil, nil, nil); }
相关文章推荐
- UISearchBar
- UI中系统自定的的宏定义-----数字
- iOS获取手机的UUID
- esasyui 和 KindEditor 在同一页面,input无法获得焦点,无法输入
- webdriver UI自动化测试执行JS脚本
- 代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧
- 22个值得收藏的android开源码-UI篇
- Android线程模型--在子线程中更新UI
- Loadrunner中参数化实战(1)-Sequential+Each iteration
- Java GUI
- Android ui 测试课堂笔记
- requestLayout和invalidate方法的区别
- Servlet(Response,Request)
- Android ui 测试课堂笔记
- Java UUID
- 使用burpsuite_pro_v1.6破解版暴力破解实例
- leetcode -- Range Sum Query 2D - Immutable -- 简单DP题目
- Webdriver UI自动化测试使用mybatis访问数据库
- UITableView - beginUpdates和endUpdates方法
- windows2008 nps+802.1