ios开发拍照,iOS开发拍照禁用麦克风权限

ios开发中怎样调用相机实现拍照功能

打开相机:

创新互联公司专注于企业营销型网站建设、网站重做改版、纳溪网站定制设计、自适应品牌网站建设、HTML5商城网站建设、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为纳溪等各大城市提供网站开发制作服务。

[cpp] view plain copy

//先设定sourceType为相机,然后判断相机是否可用(ipod)没相机,不可用将sourceType设定为相片库

UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;

// if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {

// sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

// }

//sourceType = UIImagePickerControllerSourceTypeCamera; //照相机

//sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //图片库

//sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; //保存的相片

UIImagePickerController *picker = [[UIImagePickerController alloc] init];//初始化

picker.delegate = self;

picker.allowsEditing = YES;//设置可编辑

picker.sourceType = sourceType;

[self presentModalViewController:picker animated:YES];//进入照相界面

[picker release];

打开相册:(区分pad和iphone)

for iphone:

[cpp] view plain copy

UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {

pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

//pickerImage.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

pickerImage.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:pickerImage.sourceType];

}

pickerImage.delegate = self;

pickerImage.allowsEditing = NO;

[self presentModalViewController:pickerImage animated:YES];

[pickerImage release];

for ipad:

[cpp] view plain copy

UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

//sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; //保存的相片

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

picker.delegate = self;

picker.allowsEditing = NO;//是否允许编辑

picker.sourceType = sourceType;

/*

如果从一个导航按钮处呈现,使用:

presentPopoverFromBarButtonItem:permittedArrowDirections:animated:;

如果要从一个视图出呈现,使用:

presentPopoverFromRect:inView:permittedArrowDirections:animated:

如果设备旋转以后,位置定位错误需要在父视图控制器的下面方法里面重新定位:

didRotateFromInterfaceOrientation:(在这个方法体里面重新设置rect)

然后再次调用:

- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated

*/

//UIPopoverController只能在ipad设备上面使用;作用是用于显示临时内容,特点是总是显示在当前视图最前端,当单击界面的其他地方时自动消失。

UIPopoverController *popover = [[UIPopoverController alloc]initWithContentViewController:picker];

self.imagePicker = popover;

//permittedArrowDirections 设置箭头方向

[self.imagePicker presentPopoverFromRect:CGRectMake(0, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

[picker release];

[popover release];

点击相册中的图片 货照相机照完后点击use 后触发的方法

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary

*)info

点击cancel 调用的方法

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法

我是在做一个蓝牙项目遇到这种问题的,需求是蓝牙连接后按设备按钮调用相机并且控制相机拍照,因此我选择使用自定义相机,设备发送的参数都是在一个cordova插件中实现的,它的父类是NSObject类型的。当我实现跳转到自定义的相机控制器里面时,一直出现whose view is not in the window hierarchy 这个错误,最后,我把在 viewDidLoad 里面的方法转移到 viewDidAppear 方法里面,然后就解决了。

该错误简单的说,是由于 "ViewController" 还没有被加载,就调用该 ViewController 或者 ViewController 内的方法时,就会报这个错误。在不同地方调用 ViewController,解决的方法也不太一样。

该错误一般是由于在 viewDidLoad 里面调用引起的,解决办法是转移到 viewDidAppear 方法里面

解决办法1:

解决办法2:

参考地址:

iOS使用UIImagePickerController拍照和视频录制

使用UIImagePickerController来实现在项目中添加视频和图片的功能。

+ (BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType

指定的源类型是否可用,sourceType是枚举类型:

UIImagePickerControllerSourceTypePhotoLibrary:照片库

UIImagePickerControllerSourceTypeCamera:摄像头

UIImagePickerControllerSourceTypeSavedPhotosAlbum:相簿

+ (NSArray *)availableMediaTypesForSourceType:(UIImagePickerControllerSourceType)sourceType

指定的源设备上可用的媒体类型,一般就是图片和视频

+ (BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType;

指定来源是否支持:

UIImagePickerControllerSourceTypePhotoLibrary:来自图库

UIImagePickerControllerSourceTypeCamera:来自相机

UIImagePickerControllerSourceTypeSavedPhotosAlbum:来自相册

+ (BOOL)isCameraDeviceAvailable:(UIImagePickerControllerCameraDevice)cameraDevice

指定的摄像头是否可用,cameraDevice是枚举类型:

UIImagePickerControllerCameraDeviceRear:前置摄像头

UIImagePickerControllerCameraDeviceFront:后置摄像头

+ (BOOL)isFlashAvailableForCameraDevice:(UIImagePickerControllerCameraDevice)cameraDevice

指定摄像头的闪光灯是否可用

+ (NSArray *)availableCaptureModesForCameraDevice:(UIImagePickerControllerCameraDevice)cameraDevice

获得指定摄像头上的可用捕获模式,捕获模式是枚举类型:

UIImagePickerControllerCameraCaptureModePhoto:拍照模式

UIImagePickerControllerCameraCaptureModeVideo:视频录制模式

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

代理 - 拍摄或录制完成 这里获取图片或视频信息

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

代理 - 用户取消拍摄

UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo)

保存图片到本地�相册

UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(NSString *videoPath)

能否将视频保存到相簿 更安全的判断

void UISaveVideoAtPathToSavedPhotosAlbum(NSString *videoPath, id completionTarget, SEL completionSelector, void *contextInfo)

保存视频到本地�相册

感谢崔大大的博客:iOS开发系列--音频播放、录音、视频播放、拍照、视频录制

感谢张大大的博客:AVFoundation Programming Guide(官方文档翻译)完整版中英对照

ios调用系统相机拍照和Android的区别

直接调用和间接调用。

1、ios相机拍照调用的是fuction方法直接调用相机启动程序,在启动和使用初期,同步识别其他功能及唤醒插件。

2、Android相机拍照调用的是user方法,下一步调用photo方法,再启动phoneP程序,逐步唤醒,流程式启动。

3、所以ios相机启动要比Android相机快,而且获取图片精度也高。

ios开发 用相机代码拍照,照完后存储图片的时候,图片上有一个白 框

设置了UIImagePicker的allowEditing属性为YES后,会出现一个方框,如果在其代理方法中通过

[info objectForKey:@"UIImagePickerControllerEditedImage"];

是获取编辑框区域的图片。如果想要获取整个图片的话,你需要使用下面的方法

[info objectForKey:@"UIImagePickerControllerOriginalImage"];


分享名称:ios开发拍照,iOS开发拍照禁用麦克风权限
文章起源:http://pwwzsj.com/article/dsedohj.html