Gallery on iOS - How to get on Current tab?

You must Login before you can answer or comment on any questions.

Hi folks,

Hopefully a quick one here.

I've got an app which is almost ready for deployment, but got a small issue i'd like to fix.

I'm using the picture gallery from GitHub here:

https://github.com/novelys/titanium-picture-gallery

What i'd like to do is when i tap the 'Gallery' tab in my app (i have 5 tabs) it just displays the gallery rather than sliding in another view.

Here is my code

// Import ImageGallery module
Ti.include('picturegallery.js');
 
var win = Ti.UI.currentWindow;
 
// Array with image objects
var images = [
    {path:'images/gallery/6140896705_764cc2ea1b_b.jpg'},
    {path:'images/gallery/6140901809_43dac28631_b.jpg'},
    {path:'images/gallery/6140905807_f3f8af6462_b.jpg'},
    {path:'images/gallery/6140915401_9bf8333368_b.jpg'},
    {path:'images/gallery/6141441964_db25726150_b.jpg'},
    {path:'images/gallery/6141462074_bcce6f4bb7_b.jpg'},
    {path:'images/gallery/6141473268_76c4bae7c1_b.jpg'},
    {path:'images/gallery/6504224621_df3e313f7d_b.jpg'},
    {path:'images/gallery/6504225605_78056e5b56_b.jpg'},
    {path:'images/gallery/6504226565_bfafc0e8ec_b.jpg'},
    {path:'images/gallery/6504238863_b29558668b_b.jpg'},
    {path:'images/gallery/6504239477_b802262828_b.jpg'},
    {path:'images/gallery/6504240417_32b7425f45_b.jpg'},
    {path:'images/gallery/6504240901_cd8724d30f_b.jpg'},
    {path:'images/gallery/6140901809_43dac28631_b.jpg'},
    {path:'images/gallery/6504241525_de9c4f57c1_b.jpg'},
    {path:'images/gallery/6504242077_58c4395941_b.jpg'},
    {path:'images/gallery/6713350557_37f947471e_b.jpg'},
    {path:'images/gallery/6713351187_f6a9c7f5ea_b.jpg'},
    {path:'images/gallery/6713352043_301e553994_b.jpg'},
    {path:'images/gallery/6713353047_217609975d_b.jpg'},
    {path:'images/gallery/6839418028_9b5ccf62cd_k.jpg'},
    {path:'images/gallery/6839421124_f80fe201cb_k.jpg'},
    {path:'images/gallery/6839429542_4c60f5fd7b_k.jpg'},
    {path:'images/gallery/6839434524_378db23f53_k.jpg'},
    {path:'images/gallery/6839437820_6aa26a1723_k.jpg'},
    {path:'images/gallery/6839445692_3b4cdb81f1_k.jpg'},
    {path:'images/gallery/6839448462_38c2518eed_k.jpg'},
    {path:'images/gallery/6985546863_1d5e969ae0_k.jpg'}
];
 
 
 
 
var pictureGallery = PictureGallery.createWindow({
  images: images,
  windowGroup: Titanium.UI.currentTab,
  title: 'Gallery',
 
 
 
  thumbGallery: {
    numberOfColumnPortrait: 4,
    numberOfColumnLandscape: 5,
    thumbSize: 120,
    thumbBorderColor: '#555',
    thumbBorderWidth: 0,
    thumbBackgroundColor: 'transparent',
    backgroundColor: 'transparent'
  }
 
 
});
 
 
Titanium.UI.currentTab.open(pictureGallery);
Any help would be greatly appreciated!

I've also got an app crash, caused I think by a memory leak. This doesn't happen on the simulator, only the device. That's for another post!

Simon

— asked 9 months ago by Simon Hume
4 Comments
  • can you post the code for the click event that is displaying the gallery?

    — commented 9 months ago by Aaron Saunders

  • you mean the code inside the include js? or my app.js code? the code above is all I have in my gallery.js file which is called from the app.js (i'll post that in a sec)

    — commented 9 months ago by Simon Hume

  • This is the snippet of my app.js that refers to gallery.js

    //
    // create controls tab and root window
    //
    var win5 = Titanium.UI.createWindow({  
        //title:'Gallery',
        titleImage:'images/top_gallery.png',
        barImage:'images/top_bar.png',
        barColor:'#000',
        backgroundImage:'images/background.png',
        url:'gallery.js'
    });
    var tab5 = Titanium.UI.createTab({  
        icon:'images/121-landscape.png',
        title:'Gallery',
        window:win5
    });
     
     
     
    //
    //  add tabs
    //
    tabGroup.addTab(tab1);  
    tabGroup.addTab(tab2);  
    tabGroup.addTab(tab3); 
    tabGroup.addTab(tab4); 
    tabGroup.addTab(tab5); 
     
     
    // open tab group
    tabGroup.open();

    — commented 9 months ago by Simon Hume

  • Show 1 more comment

2 Answers

My guess is that you need to pass in the actual tabGroup into the method, so try this.

var tab5 = Titanium.UI.createTab({  
    icon:'images/121-landscape.png',
    title:'Gallery',
    window:win5,
    _tabGroup : tabGroup
});
then when creating the photoGallery
var pictureGallery = PictureGallery.createWindow({
  images: images,
  windowGroup: Titanium.UI.currentTab._tabGroup, // PASS IN TABGROUP
  title: 'Gallery',
 
 
 
  thumbGallery: {
    numberOfColumnPortrait: 4,
    numberOfColumnLandscape: 5,
    thumbSize: 120,
    thumbBorderColor: '#555',
    thumbBorderWidth: 0,
    thumbBackgroundColor: 'transparent',
    backgroundColor: 'transparent'
  }
 
 
});

— answered 9 months ago by Aaron Saunders
answer permalink
2 Comments
  • Still performs the same behaviour unfortunately. I've cleaned the build and tried it again with no joy

    — commented 9 months ago by Simon Hume

  • best bet at this point would be to contact the developers... I reviewed the documentation and it says that you need to pass in the tabGroup... that is the change I made to the code.

    I would verify in the debugger that you have the tabGroup and then contact the module developer for additional assistance

    — commented 9 months ago by Aaron Saunders

Did you ever get this to work? I'm currently having the same problem.

Your Answer

Think you can help? Login to answer this question!