iOS7相機隱私判斷

來源:互聯網
上載者:User

標籤:blog   http   io   os   ar   java   for   sp   div   

轉自:http://borissun.iteye.com/blog/1992303

裝了iOS7的ip5的隱私權設定裡多了相機這一項(ip4裝iOS7就沒有)。 
如果隱私裡把你的app對應的相機給關了,那開啟就會是個黑屏。因此要判斷是不是出現了這樣的情況。 
  第一反應肯定是去UIImagePickerController裡找對應方法,然後以下2個方法看起來似乎非常滿足這個需求: 

Objective-c代碼  
  1. //這倆全不管用!!!  
  2. [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];  
  3. [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear];  



但是上邊這倆全不管用!永遠返回YES。。。 

又查了下,發現竟然需要用AVFoundation。因此需要先把AVFoundation給Link進來,然後調用: 

Objective-c代碼  
    1. BOOL isCameraValid = YES;  
    2. //判斷iOS7的宏,沒有就自己寫個,下邊的方法是iOS7新加的,7以下調用會報錯  
    3. if(isIOS7AndLater)  
    4.         {  
    5.             AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];  
    6.             if (authStatus != AVAuthorizationStatusAuthorized)  
    7.             {  
    8.                 isCameraValid = NO;  
    9.             }  
    10.         }  
    11. }  

iOS7相機隱私判斷

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.