IOS程序访问iPhone手机相册/相机来获取图片的方法
2013-03-21 17:04
711 查看
//相册获取 if(buttonIndex==0) { //确定当前所指向的图片源是否存在 if([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { //相册获取,将获取到的图片放入ImagePicker里面 self.imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary; } } //相机获取图片 if(buttonIndex==1) { if([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { //相机获取图片 self.imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera; } } //可以编辑图像,选定图片在指定方框内,进行剪切处理 self.imagePicker.allowsEditing=YES; [self presentModalViewController:self.imagePickeranimated:YES];
IOS获取手机闪光灯的操作
iPHONE获取手机闪光灯对象,制作手电筒工具 需要运入对象AVFoundation.Framework,因为闪光灯也属于多媒体设备,所以需要引入这个框架 AVCaptureDevice *device=[AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error = nil; //检测该设备是否提供闪光灯功能 if([device hasTorch]) { //与后者Unlock是成对的API,两者之间提供对闪光灯的控制 BOOL locked = [device lockForConfiguration:&error]; if(locked) { if(!ifLight) { bgImage.image=[UIImageimageNamed:@"bgon.png"]; [switchButton setImage:[UIImage imageNamed:@"on.png"] forState:UIControlStateNormal]; ifLight=YES; //开灯操作 device.torchMode =AVCaptureFlashModeOn; } else { bgImage.image=[UIImageimageNamed:@"bgoff.png"]; [switchButton setImage:[UIImage imageNamed:@"off.png"] forState:UIControlStateNormal]; ifLight=NO; //关灯操作 device.torchMode =AVCaptureTorchModeOff; } } [device unlockForConfiguration]; } //将当前View里面的Image保存到相册 #import<QuartzCore/QuartzCore.h> 要响应的方法里面添加: UIGraphicsBeginImageContext(currentView.bounds.size); //currentView 当前的view [currentView.layerrenderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage =UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage,nil, nil, nil);
相关文章推荐
- [IOS]iphone从相册或相机获取图片
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- iOS 相机拍照、相册获取照片(仿微信) 一一 拍照、图片裁剪
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- ios中从相册:相机中获取图片信息
- iOS 从相机或相册获取图片并裁剪
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- 获取IPhone相册中图片的方法(包括获取所有图片)
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- iOS App中调用相册中图片及获取最近的一张图片的方法
- android 调用系统相册选取照片或者打开相机拍照获取图片,返回时回到手机桌面,然后才会跳转到当前activity
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- 微信小程序-从相册获取图片,视频 使用相机拍照,录像上传+服务器(nodejs版)接收
- iOS图片处理(一)调用系统相机和相册获取图片,给相机添加自定义覆盖物
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- 微信小程序开发之从相册获取图片 使用相机拍照 本地图片上传
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- iOS图片处理(一)————调用系统相机和相册获取图片,给相机添加自定义覆盖物