【代码笔记】iOS-图片手势,上传照片
来源:互联网 发布:大数据行业进入壁垒 编辑:程序博客网 时间:2024/04/28 11:06
代码:
RootViewController.h
#import <UIKit/UIKit.h>@interface RootViewController : UIViewController<UIActionSheetDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>{ UIImageView *imageView;}@end
RootViewController.m
#import "RootViewController.h"@interface RootViewController ()@end@implementation RootViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self;}- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view. self.title=@"图片手势,上传照片"; //初始化背景图 [self initBackgroundView]; }#pragma -mark -functions-(void)initBackgroundView{ imageView =[[UIImageView alloc]initWithFrame:CGRectMake(100, 150, 200, 150)]; imageView.backgroundColor = [UIColor redColor]; [self.view addSubview:imageView]; [imageView setUserInteractionEnabled:YES]; UITapGestureRecognizer * clickGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickGesture:)]; [imageView addGestureRecognizer:clickGesture];}#pragma -mark -doClickActions-(void)clickGesture:(UIGestureRecognizer*)gesture{ UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"选择图片来源" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拍照" otherButtonTitles:@"本地相册", nil]; [actionSheet showInView:self.view];}#pragma -mark UIActionSheetDelegate-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"--buttonIndex-%ld",buttonIndex); UIImagePickerController *pickView = [[UIImagePickerController alloc]init]; pickView.delegate=self; if(buttonIndex==0&&!TARGET_IPHONE_SIMULATOR){ //相机 pickView.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentViewController:pickView animated:NO completion:nil]; }else if (buttonIndex==1){ //相册 pickView.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentViewController:pickView animated:NO completion:nil]; }}#pragma -mark -UIImagePickerControllerDelegate-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ UIImage * image = [info objectForKey:UIImagePickerControllerOriginalImage]; [imageView setImage:image]; [picker dismissViewControllerAnimated:NO completion:nil]; }-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{ [picker dismissViewControllerAnimated:NO completion:nil]; }- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}
0 0
- 【代码笔记】iOS-图片手势,上传照片
- iOS开发笔记--图片上传代码
- 【代码笔记】iOS-collectionView实现照片删除
- 【代码笔记】iOS-单击手势的添加
- IOS图片上传的代码
- 照片上传图片旋转(ios和android)
- 上传照片代码
- iOS上传照片
- IOS上传照片(自己的代码整理了一下)
- IOS上传照片(自己的代码整理了一下)
- IOS上传照片(自己的代码整理了一下)
- iOS学习笔记--图片上传
- iOS 上传视频 ,上传照片
- iOS图片上传代码加注释
- iOS ASIFormDataRequest上传图片 前后台代码
- IOS从相册上传照片
- 【代码笔记】iOS-图片旋转
- 【代码笔记】iOS-给背景图加上移动的手势
- 常见MVC框架比较
- 分布式计算和并行计算的区别
- ios好玩的两个属性
- java反射的应用
- iOS每日一记之————————SDwebimage图片的缓存机制
- 【代码笔记】iOS-图片手势,上传照片
- linux convert命令
- android内部搜索控件下的子控件。比如:在某个VIEW对象里(LinearLayout)中 循环所有控件
- iOS请求时清除cookie
- Behavior differences between S3 and Modern Standby
- 深度学习FPGA实现基础知识14(如何理解“卷积”运算)
- 【转帖】argument after ** must be a mapping, not list
- 计算机视觉,机器学习需要关注的网站和会议
- n个人围成一圈,从第一个人开始123报数,报到3的离开,问最后剩下的人是第几个?