首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Titanium.Media.openPhotoGallery切换到下一个屏幕

问从Titanium.Media.openPhotoGallery切换到下一个屏幕
EN

Stack Overflow用户
提问于 2012-10-17 15:02:45
回答 1查看 383关注 0票数 0

我正在用钛做一个小的应用程序,我可以点击位于窗口中的“画廊”按钮,它就会打开相册。在选择照片时,它应该移动到下一个窗口。但它所做的是,它首先关闭图片库,然后我可以看到我的第一个(按钮)屏幕,然后它打开下一个窗口。

我不想让它显示前一个窗口。有办法做到吗??

我正在向选项卡添加窗口。下面是我的代码。

代码语言:javascript
复制
cameraButton.addEventListener('click',function(e){
            chooseImageFromGallery();
        }); 



function chooseImageFromGallery(){

        var capturedImg;

        //TODO     Titanium.Media.showCamera({
        Titanium.Media.openPhotoGallery({
            success : function(event) {

                capturedImg = event.media;

                /* Condition to check the selected media */
                if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
                        var window1 = MyWindows.init(capturedImg, docImgModel, previous_win);

                                MyCommon.addWindowToTabGroup(window1);
                        win.close();
                }
            },
            cancel : function() {
                //While cancellation of the process
                activityInd.hide();
                        win.remove(activityInd);
            },
            error : function(error) {
                /* called when there's an error */
                var a = Titanium.UI.createAlertDialog({
                    titleid : 'camera'
                });
                if (error.code == Titanium.Media.NO_CAMERA) {
                    a.setMessage(L('camera_not_available'));
                } else {
                    a.setMessage('Unexpected error: ' + error.message);
                }
                a.show();
                activityInd.hide();
                win.remove(activityInd);

            }
        });

    }

init方法只是创建一个新窗口并返回它。

addWindowToTabGroup方法将其添加到当前选项卡中

代码语言:javascript
复制
addWindowToTabGroup(window){
    // tabGroup is a tab at global level declared in app.js
    // activeTab returns the current tab
    tabGroup.activeTab.open(window, {
                animated : true
            });
}

非常感谢..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-30 19:07:50

你可以这样做: 1-点击按钮,点击一个全局事件,这将打开你的相册,然后关闭你当前的窗口。

2-现在成功回调相册(当照片被选中时)编写代码打开你想要显示给你的用户的新窗口...

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12928847

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档