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,并不是直接对应到手机屏幕的一个像素 ...
随机推荐
- oracle sql日期比较
oracle sql日期比较:在今天之前: select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm ...
- UITextField里面的 placeholder颜色和字体
// placeholder 颜色 [field setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor& ...
- mysql查询所有字段(*),并且联表时需要特别注意的地方
如果不标明*是读取哪个表,确实会将所有三个表都读出来.需要小心
- PHP防止用户重复提交表单
我们提交表单的时候,不能忽视的一个限制是防止用户重复提交表单,因为有可能用户连续点击了提交按钮或者是攻击者恶意提交数据,那么我们在提交数据后的处理如修改或添加数据到数据库时就会惹上麻烦. 那么如何规避 ...
- 解决mysql数据库连接问题
设置mysql远程连接root权限 在远程连接mysql的时候应该都碰到过,root用户无法远程连接mysql,只可以本地连,对外拒绝连接.需要建立一个允许远程登录的数据库帐户,这样才可以进行在远程操 ...
- json数据交换
1.1 为什么要进行json数据交互 json数据格式在接口调用中.html页面中较常用,json格式比较简单,解析还比较方便. 比如:webservice接口,传输json数据. 1.2 s ...
- spm完成dmp在windows系统上导入详细过程
--查询dmp字符集 cat spmprd_20151030.dmp ','xxxx')) from dual; spm完成dmp在windows系统上导入详细过程 create tablespace ...
- 出现upstream sent too big header while reading response header from upstream错误
一个POS系统,出现upstream sent too big header while reading response header from upstream错误. 1.反向代理端,可以放到se ...
- Redis学习笔记(4)-List
package cn.com; import java.util.List; import redis.clients.jedis.Jedis; import redis.clients.jedis. ...
- TCP的三次握手四次挥手
一.三次握手 1.wireshark 抓包 2.TCP报文手部 注意标志位: 1).同步 SYN = 1 表示这是一个连接请求或连接接受报文. 2).只有当 ACK = 1 时确认号字段才有效.当 A ...