当从PhotoLibrary获取图像时,Cordova应用程序会导航到主屏幕 [英] Cordova app navigates to home screen when fetching image from PhotoLibrary
问题描述
使用案例:从图库中选择图片并执行回调
问题:重定向到主屏幕
从相机作品获取图片:
navigator.camera.getPicture(function(){
console.log('success');
},function(){
console.log('failure');
},{
destinationType:Camera.DestinationType.DATA_URL
});
从图库重定向到主屏幕
选择图片 navigator.camera.getPicture(function(){
console.log('success');
},function(){
console。 log('failure');
},{
destinationType:navigator.camera.DestinationType.FILE_URI,
sourceType:navigator.camera.PictureSourceType.SAVEDPHOTOALBUM
});
代码很简单,在很多地方都提到了如何选择图像的例子画廊。此代码不能在除App的主屏幕之外的任何屏幕上工作。
以下代码还会在图片选择后重定向到主屏幕。
< input type =filename =>
配置:
设备:Windows Lumia 535
设备操作系统版本:8.1
Cordova:6.1.1
Cordova插件摄像头:2.2.0
解决方案无法停止网页导航,除非在应用程序的第一页)。后来,将应用程序转换为单页应用程序,从而避免此问题。
问题可以在 https://issues.apache.org/jira/browse/CB-11295
Use Case: Choose image from Gallery and execute callbacks
Issue: Redirection to Home screen of the app after image selection from Gallery.
Getting image from Camera works:
navigator.camera.getPicture(function() { console.log('success'); },function() { console.log('failure'); } , { destinationType: Camera.DestinationType.DATA_URL });
Choosing image from Gallery redirects to the homescreen
navigator.camera.getPicture(function() { console.log('success'); },function() { console.log('failure'); } , { destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM });
The code is fairly simple and is mentioned at many places to give an example of how to choose image from Gallery. This code doesn't work on any screen other than the home screen of App. Also, no errors are reported before redirection.
The following code also results in redirection to the homescreen after image selection.
<input type="file" name="">
Configuration:
Device: Windows Lumia 535 Device OS Version: 8.1 Cordova: 6.1.1 Cordova plugin camera: 2.2.0
解决方案Wasn't able to stop the page navigation, unless on the first page of the app(without query parameters). Later, transformed the app to single page application thus avoiding this issue.
Issue can be tracked at https://issues.apache.org/jira/browse/CB-11295
这篇关于当从PhotoLibrary获取图像时,Cordova应用程序会导航到主屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!