iOS 判断应用是否有使用相机的权限

iOS  判断应用是否有使用相机的权限

NSString *mediaType =
AVMediaTypeVideo;

AVAuthorizationStatus authStatus = [AVCaptureDevice
authorizationStatusForMediaType:mediaType];

if(authStatus ==
ALAuthorizationStatusRestricted || authStatus ==
ALAuthorizationStatusDenied){

NSLog(@"相机权限受限");

return;

}

-------

全部状态

typedef NS_ENUM(NSInteger, ALAuthorizationStatus) {

ALAuthorizationStatusNotDetermined = 0,
// User has not yet made a choice with regards to this application

ALAuthorizationStatusRestricted,       
// This application is not authorized to access photo data.

// The user cannot change this application’s status, possibly due to active restrictions

//  such as parental controls being in place.

ALAuthorizationStatusDenied,           
// User has explicitly denied this application access to photos data.

ALAuthorizationStatusAuthorized        
// User has authorized this application to access photos data.

} __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);

注意:要添加 AVFoundation 库。

时间: 2024-11-13 04:37:14

iOS 判断应用是否有使用相机的权限的相关文章

ios判断app是否有打开相机的权限

#import <AVFoundation/AVCaptureDevice.h> #import <AVFoundation/AVMediaFormat.h> AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if (authStatus == AVAuthorizationStatusRestricted || authSta

iOS 判断是push还是present

iOS 判断是push还是present下面这种方法判断成功了  if (self.presentingViewController)   {      [weakSelf dismissViewControllerAnimated:YES completion:nil];    }    else {       [weakSelf.navigationController popViewControllerAnimated:YES];      }

iOS判断为空或者只为空格

本文转载至 :http://www.cnblogs.com/superhappy/archive/2012/11/08/2761403.html 经常有需求 要判断不能为空,后台老是鄙视不做非空判断的前端 ,木办法 只能写一个. 第一种想法:我不就是判断 是不是nil就可以了么.结果发现太天真,用户可以输入空格. 对于这种蛋疼的用户,只能采取蛋疼的方法: -(Bool) isEmpty:(NSString *) str { if (!str) { return true; } else { //

iOS 判断字符串中含有某个字符串rangeOfString

//_roaldSearchText if([roadTitleLab.text rangeOfString:@"格力"].location !=NSNotFound) NSLog(@"yes"); else NSLog(@"no"); iOS 判断字符串中含有某个字符串rangeOfString,布布扣,bubuko.com

ios 判断字符串为空和只为空格解决办法

ios 判断字符串为空和只为空格解决办法- (BOOL)isBlankString:(NSString *)string{ if (string == nil) { return YES; } if (string == NULL) { return YES; } if ([string isKindOfClass:[NSNull class]]) { return YES; } if ([[string stringByTrimmingCharactersInSet:[NSCharacterS

iOS 判断数组是否为空

有人说可以用([array count]==0 )来判断是否为空,都是坑,如果array为空的话,执行count就会直接报错,程序崩溃退出. 正确判断NSArray是否为空的方法:用 (!array) if(array != nil && ![array isKindOfClass:[NSNullclass]] && array.count !=0){ //执行array不为空时的操作 } 这样才是iOS判断数组是否为空的准确方式.

iOS判断判断设备类型信息

一.iOS判断判断设备机型 http://www.jianshu.com/p/591765b70ca5 1.导入 #import <sys/utsname.h> 2.代码 struct utsname systemInfo2; uname(&systemInfo2); NSString *platform = [NSString stringWithCString:systemInfo2.machine encoding:NSASCIIStringEncoding];

ios 判断邮箱是否正确

ios 判断邮箱是否正确     - (BOOL)isValidateEmail:(NSString *)Email { NSString *emailCheck = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailCh

IOS判断是否有效银行卡号

IOS判断是否有效银行卡号 by  伍雪颖 + (BOOL) isValidCreditNumber:(NSString*)value { BOOL result = NO; NSInteger length = [value length]; if (length >= 13) { result = [WTCreditCard isValidNumber:value]; if (result) { NSInteger twoDigitBeginValue = [[value substring