gpt4 book ai didi

ionic-framework - $cordovaCamera.getPicture 在 iOS 11 中不起作用

转载 作者:行者123 更新时间:2023-12-04 03:08:37 25 4
gpt4 key购买 nike

我正在使用部署在运行 ios 11 的 ipad 上的 ionic v1 应用程序。当我尝试在 ipad 中运行该应用程序并单击相机按钮时,没有任何反应。它保持原样。我试图寻找与 ios 10 类似的问题,并为 info.plst 文件添加了相关标签,还添加了跨框架安全绕过。我环顾四周,但无法解决这个问题。只有在尝试了所有可能的解决方案之后,我才提出这个问题,这些解决方案是针对 $cordovaCamera 在 ios 10 上不起作用的。即使我尝试使用 navigator.camera.getPicture() 而不是 $cordovaCamera.getPicture() 但这也没有用.

在我看来我有

<a ng-click="takePicture()" style="color:#fff;">

在我的 Controller 中

$scope.takePicture = function (options) {

var options = {
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
quality: 100,
targetWidth: 300,
targetHeight: 300,
encodingType: Camera.EncodingType.JPEG,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};

$cordovaCamera.getPicture(options).then(function(imageData) {
console.log('here');

$scope.pictureUrl = "data:image/jpeg;base64," + imageData;

console.log(imageData);
$scope.img_update = 1;
}, function(err) {
console.log(err);
});

};

在 Controller 中,我还注入(inject)了 $cordovaCamera。

在index.html中我添加了

<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; script-src &apos;self&apos; &apos;unsafe-inline&apos; &apos;unsafe-eval&apos; *; style-src  &apos;self&apos; &apos;unsafe-inline&apos; *">

在 config.xml 中,我在平台 ios 中添加了这些标签

 <plugin name="cordova-plugin-camera" spec="~2.3.0">
<variable name="CAMERA_USAGE_DESCRIPTION" value="The app would like to access the camera when you attach photos to content." />
<variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="The app would like to access the photo library when you attach images to content." />
</plugin>
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
<string>need camera access to take pictures</string>
</edit-config>
<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
<string>need to photo library access to get pictures from there</string>
</edit-config>
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>need location access to find things nearby</string>
</edit-config>
<edit-config target="NSPhotoLibraryAddUsageDescription" file="*-Info.plist" mode="merge">
<string>need to photo library access to save pictures there</string>
</edit-config>

最佳答案

更新最新的 ios 和 android 版本,然后开始执行以下步骤。

第 1 步)运行此命令

ionic cordova plugin rm camera
ionic cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="your usage message" --variable PHOTOLIBRARY_USAGE_DESCRIPTION="your usage message"

第 2 步)像这样添加选项

var options = {  
// Size
quality: 80,
targetWidth: 1024,
targetHeight: 768,
// Actions
allowEdit: false,
correctOrientation: false,
saveToPhotoAlbum: false,
// iOS
popoverOptions: CameraPopoverOptions,
// Basic
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.CAMERA,
destinationType: this.platform.is('ios') ? Camera.DestinationType.FILE_URI : Camera.DestinationType.DATA_URL,
};

你完成了。

关于ionic-framework - $cordovaCamera.getPicture 在 iOS 11 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46975445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com