2015-09-04 41 views
2

我嘗試下面的代碼通過相機捕獲圖像。此代碼在iPhone 6以下的所有設備上都可以正常工作此代碼不適用於iPHone6和iPhone6 +。它顯示一個黑屏。相機UIImagePickerController顯示設備ios8中的黑屏

enter code here 

(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
    picker.delegate = self; 
    picker.allowsEditing = YES; 

    switch (buttonIndex) 
    { 
     case 0: NSLog(@"Photo Butten Clicked"); 
      picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
      [App_Delegate.window.rootViewController presentViewController:picker animated:YES completion:nil]; 
      //   [self presentViewController:picker animated:YES completion:NULL]; 
      break; 

     case 1: NSLog(@"Camera Butten Clicked"); 
      picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
      [App_Delegate.window.rootViewController presentViewController:picker animated:YES completion:nil]; 
      // [self presentViewController:picker animated:YES completion:NULL]; 
      break; 

     default: 
      break; 
    } 
} 

回答

1

我得到了解決方案。我只是這個代碼

[self presentViewController:picker animated:YES completion:NULL]; 
更換 下面的代碼

[App_Delegate.window.rootViewController 
     presentViewController:picker 
     animated:YES 
     completion:nil]; 

2

你只要改變你的設備

的設置按照以下步驟

1)請前往裝置設定。

2)在設置列表中找到您的應用程序。

3)並給予您的應用程序相機訪問權限(在允許「應用程序名稱」訪問)。