IOS照相机的启动,图片的读取,存储demo
#import
@interface ViewController : UIViewController
@property (retain, nonatomic) IBOutlet UIImageView *imgV;
- (IBAction)openCamera:(id)sender;
- (IBAction)openPhotoLibrary:(id)sender;
- (IBAction)openSavedPhotoAlbum:(id)sender;
@end
#import "ViewController.h"
@implementation ViewController
@synthesize imgV;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setImgV:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)openCamera:(id)sender
{
//UIImagePickerController 类方法,判断源是否可用 UIImagePickerController是一个图片挑选控制器 可以通过三种途径挑选图片。Camera、PhotoLibrary、SavedPhotoAlbum
BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];//判断照相机是否可用(是否有摄像头)
if(hasCamera == YES)
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.allowsEditing = YES; //是否可编辑
[self presentModalViewController:picker animated:YES];
[picker release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你没有摄像头" delegate:nil cancelButtonTitle:@"ok!" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(@"%@",info);
// {
// UIImagePickerControllerCropRect = "NSRect: {{-1, 320}, {1937, 1937}}";
// UIImagePickerControllerEditedImage = "";
// UIImagePickerControllerMediaMetadata = {
// DPIHeight = 72;
// DPIWidth = 72;
// Orientation = 6;
// "{Exif}" = {
// ApertureValue = "2.970853654340484";
// BrightnessValue = "2.246098001053075";
// ColorSpace = 1;
// DateTimeDigitized = "2012:09:20 11:47:12";
// DateTimeOriginal = "2012:09:20 11:47:12";
// ExposureMode = 0;
// ExposureProgram = 2;
// ExposureTime = "0.06666666666666667";
// FNumber = "2.8";
// Flash = 24;
// FocalLength = "3.85";
// ISOSpeedRatings = (
// 125
// );
// MeteringMode = 5;
// PixelXDimension = 2592;
// PixelYDimension = 1936;
// SceneType = 1;
// SensingMethod = 2;
// Sharpness = 2;
// ShutterSpeedValue = "3.911199862602335";
// SubjectArea = (
// 1295,
// 967,
// 699,
// 696
// );
// WhiteBalance = 0;
// };
// "{TIFF}" = {
// DateTime = "2012:09:20 11:47:12";
// Make = Apple;
// Model = "iPhone 4";
// Software = "5.1.1";
// XResolution = 72;
// YResolution = 72;
// };
// };
// UIImagePickerControllerMediaType = "public.image";
// UIImagePickerControllerOriginalImage = "";
// }
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
imgV.image = image;
//如果想把某个UIImage对象存储到默认相册,使用下面代码
//UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
[self dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction)openPhotoLibrary:(id)sender //相册列表
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsEditing = YES; //是否可编辑
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (IBAction)openSavedPhotoAlbum:(id)sender //默认相册
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.delegate = self;
picker.allowsEditing = YES; //是否可编辑
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)dealloc {
[imgV release];
[super dealloc];
}
@end
IOS照相机的启动,图片的读取,存储demo的更多相关文章
- [置顶] ios 一个不错的图片浏览分享框架demo
demo功能:一个不错的图片浏览分享框架demo.iphone6.1 测试通过.可以浏览图片,保存,微博分享到新浪,腾讯,网易,人人等. 注:(由于各个微博的接口有时候会有调整,不一定能分享成功.只看 ...
- iOS LaunchScreen设置启动图片 启动页停留时间
问题:想实现类似微信启动页一样 设置为一个整页面的图片 问题二:iOS启动页面怎样设置多停留一会 新建的iOS 项目启动画面默觉得LaunchScreen.xib 假设想实现一张图片作为启动页,例如以 ...
- iOS LaunchScreen设置启动图片,启动页停留时间
[新建的iOS 项目启动画面默认为LaunchScreen.xib] 如果想实现一张图片作为启动页,如下图
- iOS程序的启动图片图标规范
- iOS 8 Xcode6 设置Launch Image 启动图片
本人apem http://www.mamicode.com/info-detail-494411.html 如何设置App的启动图,也就是Launch Image? Step1 1.点击Image. ...
- iOS 8 Xcode6 设置Launch Image 启动图片<转>
Step1 1.点击Image.xcassets 进入图片管理,然后右击,弹出"New Launch Image" 2.如图,右侧的勾选可以让你选择是否要对ipad,横屏,竖屏,以 ...
- 【转载】iOS 设置Launch Image 启动图片(适用iOS9)
Step1 1.点击Image.xcassets 进入图片管理,然后右击,弹出"New Launch Image" 2.如图,右侧的勾选可以让你选择是否要对ipad,横屏,竖屏,以 ...
- iOS 添加启动图片
之前添加启动图片,一直都是通过添加LaunchImage来实现,见链接 http://www.cnblogs.com/jys509/p/4856068.html 这种方法,就需要给每个尺寸添加图片. ...
- react-native ios打包 、设置图标 启动图片
在这里只记录xcode 打包操作,申请证书操作,之前已经记录过了. https://www.cnblogs.com/hellovoidworld/p/4127576.html 参考了这篇文章,只是可 ...
随机推荐
- 08-----pymysql模块使用
pymysql的下载和使用 exctue() 之sql注入 增.删.改:conn.commit() 查:fetchone.fetchmany.fetchall 一.pytmysql的下载和使用 ...
- python 数据可视化---Anscombe’s quartet
import seaborn as sns sns.set(style="ticks") # Load the example dataset for Anscombe's qua ...
- 进入BIOS的步骤
查看自己的BIOS版本 $ systeminfo 对号入座,电脑进入BIOS的两种实用方法
- python面向对象实例
——王宇阳 总结 (Code_boy)2018年11月16日 class Person: name='xxx' age=20 p=Person() #p为实例对象 print(p.name,p.age ...
- RTT设备与驱动之串口
有一般收发.中断方式.DMA方式: rt_device_t rt_device_find(const char* name); rt_err_t rt_device_open(rt_device_t ...
- PCB的版本控制
http://club.szlcsc.com/article/details_1783_1.html 转载自:http://www.amobbs.com/thread-5606014-1-1.html ...
- 3DSMAX 安装失败
AUTO Uninstaller 更新下载地址 1.选择3DSMAX 2.选择3DSMAX的版本 3.点击“开始卸载”,然后重新安装就可以了
- JavaScript操作符(=?,)优先级
JavaScript操作符优先级: 关于最后3个运算符的优先级比较,下面通过一个实例来具体说明: var a,b,c; a = 3,4,5; b = a--,--a,a; c = a ? b++ : ...
- Ubuntu15.10下安装Docker
1.首先查看linux系统版本 head -n 1 /etc/issue 2.升级包管理器 sudo apt-get update sudo apt-get install apt-transport ...
- maven常用依赖
HttpServletRequest HttpServletResponse <dependency> <groupId>javax.servlet</groupId&g ...