使用相机拍照后我的应用程序崩溃了。 在iOS 11上使用titanium SDK 6.3.0之前从未发生这种情况。 有没有人有办法解决吗? 谢谢
Titanium.Media.showCamera({
success: function(event) {
lObjPhoto = event.media;
parameters.callbackApply(lObjPhoto);
},
cancel: function() {
lObjPhoto = null;
lObjThumb = null;
parameters.callbackApply(lObjPhoto);
},
error: function(error) {
lObjPhoto = null;
var a = Titanium.UI.createAlertDialog({title:'Camera', ok: 'Ok'});
if (error.code == Titanium.Media.NO_CAMERA) a.setMessage('Device does not have camera');
else a.setMessage('Unexpected error: ' + error.code);
a.show();
parameters.callbackApply(lObjPhoto);
},
allowImageEditing: false,
saveToPhotoGallery: false,
})
答案 0 :(得分:0)
确保您在tiapp.xml中使用这些属性:NSPhotoLibraryUsageDescription和NSCameraUsageDescription。
<ios>
...
<plist>
<dict>
...
<key>NSPhotoLibraryUsageDescription</key>
<string>Gallery permissions required</string>
<key>NSCameraUsageDescription</key>
<string>Camera permissions required</string>
</dict>
</plist>
</ios>
答案 1 :(得分:0)
也可以使用Marshmallow及以上代码接受许可
var permissions = ['android.permission.CAMERA', 'android.permission.READ_EXTERNAL_STORAGE'];
Ti.Android.requestPermissions(permissions, function(e) {
if (e.success) {
//Action
Ti.API.info("Success");
});
} else {
Ti.API.info("ERROR: " + e.error);
}
});