iOS 从手机相册里选取图片
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
#import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; UINavigationController *root = [[UINavigationController alloc] initWithRootViewController:[[RootViewController alloc] init]];
self.window.rootViewController = root; [self.window makeKeyAndVisible];
return YES;
} @end
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
#import "RootViewController.h" @interface RootViewController ()<UIActionSheetDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate> @property (strong, nonatomic) UIButton *btn; @end @implementation RootViewController @synthesize btn; - (void)loadView
{
[super loadView];
btn= [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(, , , );
btn.backgroundColor = [UIColor purpleColor];
[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
} - (void)btnAction:(UIButton *)sender
{
UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"从手机相册选取", nil];
[actionsheet showInView:self.view];
} - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == ) {
UIImagePickerController *imagepicker = [[UIImagePickerController alloc] init];
imagepicker.delegate = self;
imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagepicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
imagepicker.allowsEditing = YES;
[self presentViewController:imagepicker animated:YES completion:^{}];
}
} #pragma amrk - 图片选择完成 -
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[picker dismissViewControllerAnimated:YES completion:^{
[btn setImage:image forState:];
}];
} @end
iOS 从手机相册里选取图片的更多相关文章
- iOS从手机相册选择一张照片并显示 Objective-C
		要先给app设置访问相册的权限: 在项目的Info.plist文件里添加Privacy - Photo Library Usage Description权限 ViewController.h: #i ... 
- ios最新调用手机相册选取头像(UIActionSheet过期)
		由于 UIActionSheet过期所以可以使用如下调用手机相册 前提不要忘记添加代理如下两个 UIImagePickerControllerDelegate,UINavigationControll ... 
- iOS 如何监听用户在手机设置里改变了系统的时间?
		如何监听用户未退出APP但通过Home键在手机设置里改变了系统的时间? 用户虽未退出APP,但是当它按Home键退到后台时 ,会调用该方法: - (void)applicationDidEnterBa ... 
- PhoneGap奇怪的现象:File FileTransfer download, 手机相册检测不到下载下来的图片(解决)
		我有个从服务器下载相片的功能在使用 File FileTransfer download api时,碰到了很奇怪的现象:图片已经从服务器里下载了,手机文件夹里也可以看到下载过来的图片,但是我的手机相册 ... 
- 微信公众号与HTML 5混合模式揭秘2——分享手机相册中照片
		本书是分享微信jssdk开发的第二篇. 4.2.1 项目需求 需求说明:实现微信端的手机用户,点击按钮选取1张图片,分享到朋友圈. 4.2.2 需求分解 通过对需求的了解,可以将其分解为: ( ... 
- 三种方法,刷新 Android 的 MediaStore!让你保存的图片立即出现在相册里!
		公众号原标题:测试:"系统相册里怎么看不到我刚保存的图片,是我操作不对吗?" 一.序 Hi,大家好,我是承香墨影! App 内,创建一个文件并保存文件到本地的需求,是很常见的 I/ ... 
- iOS中 读取相册,调用系统相机 技术分享
		技术内容:分别读取相册以及调取相机,将图片显示到imageView上 布局: 1.创建imageView 和 button 并为button一个关联pickerImage的事件 <div sty ... 
- WebApp调用手机相册或摄像头、拨打电话
		WebApp调用手机相册或摄像头.拨打电话 一.总结 一句话总结:input标签,指定type为file,选择好对应的accept即可.camera——相机,相应的accept为image : cam ... 
- [Cordova] 手机网页里的1px
		[Cordova] 手机网页里的1px 1px的显示 Cordova让开发人员可以使用HTML页面,来开发APP的显示内容.但是在手机上,HTML页面里定义的1px,并不是直接对应到手机屏幕的一个像素 ... 
随机推荐
- angular+selecte2(angular ng-repeat渲染)
			一.页面代码 <select id="sponsorId" select2 ng-model="sponsorSelectedObj" ng-change ... 
- 【转载 来自sdnlab】 开放网络没那么简单
			链接:开放网络没那么简单 本文是云杉网络工程师张攀对当前开源网络技术现状的一些思考和探索. 开放网元.释放数据的价值 从2012年开始至今,网络行业明显是O字辈的天下.所有我接触过了解过的组织和项目, ... 
- 利用SpannableString设置文本
			private void setTips(){ String big = "大字深色"; String small = "小字淡色"; Spannable ti ... 
- your project contains error(s),please fix them before running your application.错误总结
			Android开发中的问题总是多种多样,今天我来总结一个浪费了我一个晚上的错误T-T:your project contains error(s),please fix them b ... 
- MySQL安装图解教程
			安装文件存放路径:不能有中文和空格! 校验 1 安装MySQL 2 校验MySQL 登录MySQL:mysql -uroot -p123 退出MySQL:exit | quit 查看数据库:show ... 
- 用正则验证字符串格式,形如:A)XXX B)XXXX C)XXX
			今天遇到个小功能,要验证某个英文选项是否正确,例如:A)accumulate B)circling C)communities D)competition E)domestic F)financi ... 
- UNION 查询中的排序
			MSSQL 不允许在UNION查询中使用 ORDER BY 因此,当我们需要这种功能的时候,就需要绕一些弯路. 比如有一张学生表student 和教师表 teacher , 我们要查询所有的教师学生的 ... 
- firs tday
			1.JVM 解析: 2.JDBC 解析: 3.Spring 
- CSS3新添加的属性
			1.圆角设置 border-radius:15px 50px 30px 5px; /*四个值: 第一个值为左上角,第二个值为右上角,第三个值为右下角,第四个值为左下 角. 三个值: 第一个值为左上角, ... 
- 消息队列系列(一):.Net平台下的消息队列介绍
			本系列主要记录最近学习消息队列的一些心得体会,打算形成一个系列文档.开篇主要介绍一下.Net平台下一些主流的消息队列框架. RabbitMQ:http://www.rabbitmq.com ... 
