iosios 调用照相机机需要什么库文件

您需要登录后才可以操作 |
该用户从未签到
IOS 10 上传控件,调用原生拍照或照片图库功能,出现黑屏
引擎版本[sdksuit_3.4_]&其他问题[]&
iphone/ipad
本帖最后由 诺威品牌设计 于
09:34 编辑
img_0276.png (101.91 KB, 下载次数: 0)
Html文件选择器
09:24 上传
img_0277.png (101.93 KB, 下载次数: 0)
调用原生功能
09:24 上传
img_0279.png (82.45 KB, 下载次数: 0)
09:24 上传
img_0280.png (129.08 KB, 下载次数: 0)
但是能拍到一张黑黑的图片
09:24 上传
IOS 10 上传控件(没使用AppCan 的组件,说是上传控件,其实是直接写在Html 5页面里的自带文件选择器&input type=&file&&),调用原生拍照或照片图库功能,出现黑屏。
和这个帖子的症状比较贴切:
IOS 10以下系统使用拍照或照片图库正常;但IOS 10以上系统出现黑屏。看了很多帖子和搜遍度娘无果。
所以我想这是Apple 升级了IOS 10 之后,AppCan 引擎版本和IOS 10 的一些兼容问题。
收集解决办法:
① 所谓状态栏的问题(IOS 10 因为状态栏遮罩还是什么鬼的问题。),测试打包显示状态栏和不显示的2种APP,问题依旧。
② 权限问题:网上有2种说法;
o Info.plist 里面添加相关权限。因本人无Mac 故不知。
o config.xml,AppCan官方的解释,添加该文件的隐私权限配置。因没有安装IDE,不能直接修改config.xml。
该用户从未签到
版主救急谢谢
TA的每日心情开心 17:52签到天数: 127 天连续签到: 1 天[LV.7]常住居民III
你试一下最新4.0的引擎
注意事项请参考:
该用户从未签到
IOS下同样是这样的效果,用的是Web App(隐私权限无法配置),如果用浏览器访问有权限提示,但在App里面没有权限提示直接就黑屏了
AppCan官方微信IOS调用照相机和相册功能
我的图书馆
IOS调用照相机和相册功能
打开相机:
//先设定sourceType为相机,然后判断相机是否可用(ipod)没相机,不可用将sourceType设定为相片库&&&&&&UIImagePickerControllerSourceType&sourceType&=&UIImagePickerControllerSourceTypeC&&//&&&&if&(![UIImagePickerController&isSourceTypeAvailable:&UIImagePickerControllerSourceTypeCamera])&{&&//&&&&&&&&sourceType&=&UIImagePickerControllerSourceTypePhotoL&&//&&&&}&&&&&&//sourceType&=&UIImagePickerControllerSourceTypeC&//照相机&&&&&&//sourceType&=&UIImagePickerControllerSourceTypePhotoL&//图片库&&&&&&//sourceType&=&UIImagePickerControllerSourceTypeSavedPhotosA&//保存的相片&&&&&&UIImagePickerController&*picker&=&[[UIImagePickerController&alloc]&init];//初始化&&&&&&picker.delegate&=&&&&&&&picker.allowsEditing&=&YES;//设置可编辑&&&&&&picker.sourceType&=&sourceT&&&&&&[self&presentModalViewController:picker&animated:YES];//进入照相界面&&&&&&[picker&release];&&
打开相册:(区分pad和iphone)
for iphone:
UIImagePickerController&*pickerImage&=&[[UIImagePickerController&alloc]&init];&&&&&&if([UIImagePickerController&isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])&{&&&&&&&&&&pickerImage.sourceType&=&UIImagePickerControllerSourceTypePhotoL&&&&&&&&&&//pickerImage.sourceType&=&UIImagePickerControllerSourceTypeSavedPhotosA&&&&&&&&&&pickerImage.mediaTypes&=&[UIImagePickerController&availableMediaTypesForSourceType:pickerImage.sourceType];&&&&&&&&&&&&&&&&}&&&&&&pickerImage.delegate&=&&&&&&&pickerImage.allowsEditing&=&NO;&&&&&&[self&presentModalViewController:pickerImage&animated:YES];&&&&&&[pickerImage&release];&&
UIImagePickerControllerSourceType&sourceType&=&UIImagePickerControllerSourceTypePhotoL&&&&&&//sourceType&=&UIImagePickerControllerSourceTypeSavedPhotosA&//保存的相片&&&&&&UIImagePickerController&*picker&=&[[UIImagePickerController&alloc]&init];&&&&&&picker.delegate&=&&&&&&&picker.allowsEditing&=&NO;//是否允许编辑&&&&&&picker.sourceType&=&sourceT&&&&&&/*&&&&&&如果从一个导航按钮处呈现,使用:&&&&&&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&=&&&&&&&//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
点击cancel 调用的方法
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
例子下载地址:
发表评论:
TA的最新馆藏[转]&[转]&[转]&[转]&[转]&[转]&Pages: 1/2
主题 : ios7调用相机黑屏
级别: 新手上路
可可豆: 16 CB
威望: 21 点
在线时间: 120(时)
发自: Web Page
ios7调用相机黑屏&&&
我在ios7系统上调用相机,偶尔会出现黑屏的情况,频率大概在10次出现一次,请问各位大神有没有人知道是怎么回事?
附上调用相机代码如下:
&&&&&&&&UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
& & & & if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
& & & & & & sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
& & & & }
& & & & UIImagePickerController *picker = [[UIImagePickerController alloc] init];//初始化
& & & & picker.delegate = self;
& & & &&picker.sourceType = sourceT
& & & &&[self presentViewController:picker animated:YES completion:NULL];//进入照相界面
级别: 新手上路
UID: 116803
可可豆: 159 CB
威望: 107 点
在线时间: 251(时)
发自: Web Page
没遇到过
代码很简单,也没什么问题
你先看看只是一台设备这样还是所有设备都这样,应该是个例
越狱、重启,各种折腾,阿门!!!
级别: 新手上路
可可豆: 16 CB
威望: 21 点
在线时间: 120(时)
发自: Web Page
不是个例,ios7系统出现的问题
级别: 新手上路
UID: 116803
可可豆: 159 CB
威望: 107 点
在线时间: 251(时)
发自: Web Page
那帮不了你了,可能其他的代码、第三方库、或者设置什么的导致的?
我项目上用的照相机没问题,我贴上代码:
//判断是否可以打开相机,模拟器此功能无法使用
& & if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
&& & & &
& & & & UIImagePickerController * picker = [[UIImagePickerController alloc]init];
& & & & picker.delegate = self;
& & & & picker.allowsEditing = YES;& //是否可编辑
& & & & //摄像头
& & & & picker.sourceType = UIImagePickerControllerSourceTypeCamera;
& & & & [self presentViewController:picker animated:YES completion:nil];
基本都一样
级别: 新手上路
可可豆: 6 CB
威望: 7 点
在线时间: 291(时)
发自: Web Page
解决了吗,朋友,我也遇见这个问题。。。请指教啊,各种蛋疼。
级别: 新手上路
可可豆: 16 CB
威望: 21 点
在线时间: 120(时)
发自: Web Page
没解决啊!通过测试,觉得跟内存有点关系!
级别: 新手上路
UID: 57395
可可豆: 106 CB
威望: 38 点
在线时间: 156(时)
发自: Web Page
我今天也出现了,黑一段时间以后就好了,不知道是不是iOS7的bug
级别: 新手上路
UID: 285136
可可豆: 3 CB
威望: 5 点
在线时间: 0(时)
发自: Web Page
在AppDelegate中设置你的self.window.backgroundCloor = [uicolor whiteColor];
级别: 新手上路
可可豆: 12 CB
威望: 17 点
在线时间: 39(时)
发自: Web Page
朋友解决了吗,我也遇到这个问题了
级别: 新手上路
可可豆: 12 CB
威望: 17 点
在线时间: 39(时)
发自: Web Page
朋友你的问题解决了吗,我也遇到这个问题了,打开照相机会黑屏一下,过一下又好了
Pages: 1/2
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版AQPhotoPicker简单易用地调出相机及图片库--io...
AQPhotoPicker简单易用地调出相机及图片库--ios
作者:不知不为所措
资源类型:
运行环境:
分享一款iOS中的简单易用地调出相机及图片库, 只需要几行,就调能通过回调,获取图片库图片,或者获取相机照片,很值得学习哦。
服务热线:400-678-8266ios 调用系统照片库/拍照/录像 - 简书
ios 调用系统照片库/拍照/录像
在iOS中要拍照和录制视频最简单的方法就是使用UIImagePickerController。UIImagePickerController继承于UINavigationController,我们可以用它来选取照片,还可以用来拍照和录制视频。
要用UIImagePickerController来拍照或者录制视频通常可以分为如下步骤:
1. 创建UIImagePickerController对象。
2. 指定拾取源,平时选择照片时使用的拾取源是照片库或者相簿,此刻需要指定为摄像头类型。
3. 指定摄像头,前置摄像头或者后置摄像头。
4. 设置媒体类型mediaType,注意如果是录像必须设置,如果是拍照此步骤可以省略,因为mediaType默认包含kUTTypeImage(注意媒体类型定义在MobileCoreServices.framework中)
5. 指定捕获模式,拍照或者录制视频。(视频录制时必须先设置媒体类型再设置捕获模式)
6. 展示UIImagePickerController(通常以模态窗口形式打开)。
7. 拍照和录制视频结束后在代理方法中展示/保存照片或视频。
当然这个过程中有很多细节可以设置,例如是否显示拍照控制面板,拍照后是否允许编辑等等,通过上面的属性/方法列表相信并不难理解。
下面用代码来展示下UIImagePickerController的使用:
MyViewController
#import "GetFilePath.h"
@interface MyViewController () &UINavigationControllerDelegate, UIImagePickerControllerDelegate&
@implementation MyViewController
//触发事件:拍照
- (void)addCamera
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate =
picker.allowsEditing = YES; //可编辑
//判断是否可以打开照相机
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//UIImagePickerControllerSourceTypeSavedPhotosAlbum:相机胶卷
picker.sourceType = UIImagePickerControllerSourceTypeC
} else { //否则打开照片库
picker.sourceType = UIImagePickerControllerSourceTypePhotoL
[self presentViewController:picker animated:YES completion:nil];
//触发事件:录像
- (void)addVideo
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate =
picker.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker.sourceType = UIImagePickerControllerSourceTypeC
picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
picker.videoQuality = UIImagePickerControllerQualityTypeM //录像质量
picker.videoMaximumDuration = 600.0f; //录像最长时间
picker.mediaTypes = [NSArray arrayWithObjects:@"public.movie", nil];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"当前设备不支持录像功能" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
//跳转到拍摄页面
[self presentViewController:picker animated:YES completion:nil];
#pragma mark - UIImagePickerControllerDelegate
//拍摄完成后要执行的代理方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([mediaType isEqualToString:@"public.image"]) {
//得到照片
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//图片存入相册
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
NSString *imagePath = [GetFilePath getSavePathWithFileSuffix:@"png"];
success = [fileManager fileExistsAtPath:imagePath];
if (success) {
[fileManager removeItemAtPath:imagePath error:nil];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:imagePath atomically:YES]; //写入本地
success = [fileManager fileExistsAtPath:imagePath];
if (success) {
NSLog(@"图片写入成功,image路径:%@",imagePath);
} else if ([mediaType isEqualToString:@"public.movie"]) {
NSString *videoPath = [GetFilePath getSavePathWithFileSuffix:@"mov"];
success = [fileManager fileExistsAtPath:videoPath];
if (success) {
[fileManager removeItemAtPath:videoPath error:nil];
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSData *videlData = [NSData dataWithContentsOfURL:videoURL];
[videlData writeToFile:videoPath atomically:YES]; //写入本地
//存储数据
success = [fileManager fileExistsAtPath:videoPath];
if (success) {
NSLog(@"media 写入成功,video路径:%@",videoPath);
[self dismissViewControllerAnimated:YES completion:nil];
//进入拍摄页面点击取消按钮
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
[self dismissViewControllerAnimated:YES completion:nil];
GetFilePath
#import &Foundation/Foundation.h&
@interface GetFilePath : NSObject
//获取要保存的本地文件路径
+ (NSString *)getSavePathWithFileSuffix:(NSString *)
//获取录像的缩略图
+ (UIImage *)getVideoThumbnailWithFilePath:(NSString *)fileP
+ (UIImage *)getImage:(NSString *)fileP
#import "GetFilePath.h"
#import &MediaPlayer/MediaPlayer.h&
#import &AVFoundation/AVFoundation.h&
@implementation GetFilePath
+ (NSString *)getSavePathWithFileSuffix:(NSString *)suffix
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [paths objectAtIndex:0];
NSDate *date = [NSDate date];
//获取当前时间
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyyMMddHHmmss"];
NSString *curretDateAndTime = [dateFormat stringFromDate:date];
//获取用户userID
NSDictionary *userDic= [[NSUserDefaults standardUserDefaults] objectForKey:UserInformation];
//命名文件
NSString *fileName = [NSString stringWithFormat:@"%@%@.%@",userDic[@"UserID"],curretDateAndTime,suffix];
//指定文件存储路径
NSString *filePath = [documentPath stringByAppendingPathComponent:fileName];
return fileP
+ (UIImage *)getVideoThumbnailWithFilePath:(NSString *)filePath
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:filePath]];
moviePlayer.shouldAutoplay = NO;
UIImage *image = [moviePlayer thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
+ (UIImage *)getImage:(NSString *)filePath
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
NSURL *url = [NSURL fileURLWithPath:filePath];
AVURLAsset *urlAsset = [[AVURLAsset alloc] initWithURL:url options:options];
AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset];
generator.appliesPreferredTrackTransform = YES;
generator.maximumSize = CGSizeMake(60, 60);
CGImageRef imageRef = [generator copyCGImageAtTime:CMTimeMake(10, 10) actualTime:NULL error:nil];
UIImage *image = [UIImage imageWithCGImage:imageRef];

我要回帖

更多关于 ios 调用本地文件 的文章

 

随机推荐