- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我希望用户能够拍照或从手机图库中选择图片。
我成功地拍照并获得了 imageURI。
我使用 Genymotion 作为模拟器,因为我需要访问一些功能,例如相机。我知道还有其他一些解决方案。模拟时调试起来有点困难,但这是我目前发现的访问相机的唯一方法。因此我看不到第二部分发生了什么(从图库中选择图像)。
$scope.uploadPopup = function() {
var uploadPopup = $ionicPopup.show({
title: "Edit profile's picture",
templateUrl: 'templates/partials/upload-img.html',
buttons: [
{
text: '',
type: 'button-energized icon-center ion-ios7-camera',
onTap: function(e) {
// e.preventDefault() will stop the popup from closing when tapped.
e.preventDefault();
alert('Getting camera');
Camera.getPicture({
quality: 100,
saveToPhotoAlbum: false
}).then(function(imageURI) {
alert(imageURI);
$scope.lastPhoto = imageURI;
}, function(err) {
alert(err);
});
}
},
{
text: 'From gallery',
type: 'button',
onTap: function(e) {
e.preventDefault();
alert('Getting gallery');
Camera.getPicture({
quality: 100,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
}).then(function(imageURI) {
alert(imageURI);
$scope.lastPhoto = imageURI;
}, function(err) {
alert(err);
});
}
}
]
});
};
服务:
app.factory('Camera', ['$q', function($q) {
return {
getPicture: function(options) {
var q = $q.defer();
navigator.camera.getPicture(function(result) {
// Do any magic you need
q.resolve(result);
}, function(err) {
q.reject(err);
}, options);
return q.promise;
}
}
}]);
这是正确的做法吗?有什么提示或想法吗?
更新:
当我添加时:
sourceType: Camera.PictureSourceType.CAMERA
到第一个功能(从相机拍照)。它不起作用了。虽然没有(可能使用默认的)它确实有效。
最佳答案
当我添加 sourceType 而不是使用默认 sourceType(CAMERA) 时
sourceType: Camera.PictureSourceType.CAMERA
它不再工作了,所以我猜这里出了点问题。
正确的语法是:
navigator.camera.PictureSourceType.CAMERA
或(有不同的选项):
navigator.camera.PictureSourceType.PHOTOLIBRARY
不确定为什么是“navigator.camera”而不是“Camera”,我猜“Camera”是“navigator.camera”的别名。
关于android - ionic / Cordova : Upload image from phone's gallery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30080003/
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: how to disable fling in android gallery 我有一个带有 Gallery
我像这样使用 Lightbox: $('#gallery a').lightBox(); html 看起来像这样:
如果之前有人问过这个问题,我深表歉意,但我已经尝试用谷歌搜索这个主题,但没有任何好的结果。基本上,我正在尝试寻找 Google 已决定弃用的 Gallery 小部件的替代品。到目前为止,我有以下候选人
使用Blueimg Gallery我想知道如何在单击 img class=".slide-content" 希望有帮助。 关于jquery - Blueimp 画廊 : Always show "bl
我希望有一个 android 画廊,可以容纳不同宽高比的图像。我想要的是画廊中图像的 CENTER_CROP。然而,当我将图像缩放类型设置为此时,图像会超出图库图像边界。 当然,FIT_XY 会导致图
我正在为 ipad 构建一个应用程序,它使用 youtube api 来获取视频缩略图并将其呈现在图库中(就像 ipad 上的 native youtube 应用程序一样)。基本上它只是 UIScro
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
这应该是关于MEDIA RESCAN的常见问题解答 我的环境: 安卓 4.1.1 com.android.gallery3d 是管理缓存和缩略图的 Gallery 应用程序包。 图库首选项位于: /d
我正在做一个 phoneGap 应用程序,它对图片进行一些更改并将其保存回//sdcard/Download/文件夹。使用 ES File Explorer 等第三方应用程序,我可以看到图片已添加到下
我有一个展示一些扑克牌图像的画廊。每张卡片之间间隔 20dp。 当我从一张图片移动到下一张图片时,画廊会略微滚动到下一张图片之外,然后自行更正回图片。 另一个几乎肯定相关的问题是图像没有干净地滚动到视
大家好,请帮我解决一下 android 中的菜单问题。我想将此画廊作为我的应用程序的网格菜单。请指导我如何将名称放在图像下,如果 iclick 在特定图像上,新 Activity 应该打开,最后单击菜
我想构建一个图库应用,从我的文件夹中获取照片列表并将其显示在一个页面中。 我降低了图像的分辨率,这样图库加载速度会更快,但加载仍然需要很长时间。 我认为问题是每次打开应用程序时都会加载每个文件。我该如
我正在考虑启动一个能够根据标签搜索/过滤图像的图库应用程序。我的问题: 我想经常更新图像,所以...我应该在网络服务器上托管图像并托管应用程序可以调用的 XML 文件,其中包含图像路径、缩略图路径和标
好的,所以我最近刚刚学会了如何使用 jquery 来切换目标 div 的图像源,但是生成的图像加载了一个损坏的链接。有一段时间,我什至不知道如何尝试这样做。事实上,脚本实际上改变了目标 div 的图像
我有一个问题,也许是一个愚蠢的问题,但我认为它很重要。 为什么参数:convertView(View)就对了 public View getView(int position, View conver
默认情况下,当单击图库项目时,图库会自动滚动以将被单击的项目居中。我怎样才能覆盖这种行为?我不希望画廊在单击时滚动到中心,我希望它留在原处。 最佳答案 我认为这是一个正确的解决方案: @Ove
我查看了 API 演示,他们有一个画廊示例,其中仅显示文本,代码仅使用 Cursor ,但我想使用 String 数组。我怎样才能实现使用它?这是 API 演示中示例的代码: Curs
imageView.setLayoutParams(new Gallery.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowMa
我在我的应用中使用了图库。 因为我在每个图库项目中都有两张图片,如下所示 每张兔子和老鼠的图片都合并为一个图库项目。 所以我为两个图像都提供了 onclickListener,但如果我这样提供,我就无
是否可以使用此项目中的异步图像加载器 http://open-pim.com/tmp/LazyList.zip与画廊小部件?我试过: public View getView(int posi
我是一名优秀的程序员,十分优秀!