iOS9上的相机权限似乎是iPhone 6特有的

时间:2016-06-20 23:02:50

标签: ios iphone permissions camera iphone-6

在尝试拍照时,我的应用程序的试飞版本存在问题。 在大多数设备上一切正常,但似乎出现了问题,特别是在iPhone 6上。 因为我们没有iPhone 6,所以如果没有控制台输出,很难找出问题所在。

我们的相机调用代码如下所示(请注意其中一些特定于Moai平台):

int MOAIAppIOS::_takeCamera( lua_State* L ) {

int x, y, width, height = 0;
NSUInteger sourceType;

MOAILuaState state ( L );
if ( state.IsType ( 1, LUA_TFUNCTION )) {
    MOAIAppIOS::Get ().mOnTakeCameraCallback.SetRef ( state, 1 );
}

sourceType = state.GetValue < NSUInteger >( 2, 0 );
x = state.GetValue < int >( 3, 0 );
y = state.GetValue < int >( 4, 0 );
width = state.GetValue < int >( 5, 0 );
height = state.GetValue < int >( 6, 0 );

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
 {
     if (granted == true)
     {
         UIImagePickerNoRotate *ipc = [[UIImagePickerNoRotate alloc]
                                       init];
         UIWindow* window = [[ UIApplication sharedApplication ] keyWindow ];
         UIViewController* rootVC = [ window rootViewController ];

         ipc.delegate = MOAIAppIOS::Get ().mTakeCameraListener;
         ipc.sourceType = sourceType;
         [rootVC presentViewController:ipc animated:YES completion:nil];

     }
     else
     {
         NSLog(@"denied");
     }

 }];



return 0;
}
void MOAIAppIOS::callTakeCameraLuaCallback (NSString *imagePath) {
    MOAILuaRef& callback = MOAIAppIOS::Get ().mOnTakeCameraCallback;
    MOAIScopedLuaState state = callback.GetSelf ();
    state.Push ([imagePath UTF8String]);
    state.DebugCall ( 1, 0 );
    NSLog(@"callback sent");
}

我还在pList中添加了以下内容:

<key>NSCameraUsageDescription</key>
<string>Camera is used to add custom items to the game</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone is used to record custom items for the game</string>

这些似乎是一个非常相似的问题:
iOS Camera permissions doesn't appear under settings in some devices

Permission to take photo OR get image from library not shown in iOS9 (Xcode 7beta, Swift2)

但是我已经尝试了那里的所有修复无济于事。

1 个答案:

答案 0 :(得分:1)

当您的应用程序Info.plist文件包含密钥时,此问题会出现在iOS 9中:&#34; CFBundleDisplayName&#34;空字符串值。

您可以在那里输入您的应用名称,它应该有效。