ScrollableView in TableViewRow

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

Hi everyone, I am trying to get a ScrollableView inside a TableViewRow to work on the iPhone Simulator. The row is shown, but the images defined as a part of the ScrollableView are not.

function loadALaUneFeed(){
        require('BusinessLogic/loadALaUne').loadALaUne(
            function update(articles){
                //Vider le tableau pour mettre a jour le "à la une" quand on clique sur "refresh"
                scrollableViewAlaUne.views = [];
                for(var i=articles.length-1; i>=0; i--)
                {               
                    if(aLaUnePremierChargement) {
                        imagesAlaUne[i] = Titanium.UI.createImageView({
                            bottom: 7,
                            width: Ti.UI.SIZE, height: '100%',
                            defaultImage: 'images/logo.png',
                            index: i,
                            estChargee: false,
                            titreArticle: articles[i].titre,
                            imageArticle: articles[i].image,
                            contenuArticle: articles[i].contenu,
                            dateArticle: articles[i].date,
                            urlArticle: articles[i].url
                        });
                    }
 
                    scrollableViewAlaUne.addView(imagesAlaUne[i]);
                }
 
                var viewsArray;
                //Si premier chargement
                if(aLaUnePremierChargement) {
                    aLaUnePremierChargement = false;
 
                    scrollableViewAlaUne.currentPage = imagesAlaUne.length-1;
                    viewsArray = scrollableViewAlaUne.views;
                    activeView = viewsArray[imagesAlaUne.length-1];
 
                    for(var j=0; j<imagesAlaUne.length-1; j++) {
                        imagesAlaUne[j].addEventListener('load', function(e) {
                            e.source.estChargee = true;
                            imagesAlaUne[e.source.index + 1].image = articles[e.source.index + 1].image;
                            // afficher titre si (on est positionné sur cette image && "à la une" est activée)
                            if(activeViewIndex == e.source.index) {
                                viewTitreAlaUne1.visible = true;
                                viewTitreAlaUne2.visible = true;
                            }
                        });
                    }
 
                    imagesAlaUne[imagesAlaUne.length-1].addEventListener('load', function(e) {
                        e.source.estChargee = true;
                        if(activeViewIndex == e.source.index) {
                            viewTitreAlaUne1.visible = true;
                            viewTitreAlaUne2.visible = true;
                        }
                    });
                }
                //Si pas premier chargement
                else {
                    var currentPage = (imagesAlaUne.length-1) - activeViewIndex;
                    scrollableViewAlaUne.currentPage = currentPage;
                    viewsArray = scrollableViewAlaUne.views;
                    activeView = viewsArray[currentPage];
                }
 
                imagesAlaUne[0].image = articles[0].image;
                titreAlaUne.text = activeView.titreArticle;
 
                var scrollabbleViewRow = Ti.UI.createTableViewRow({});
 
                scrollabbleViewRow.add(scrollableViewAlaUne);
                table.push(scrollabbleViewRow);
 
                loadCaricature();
            },
 
            function error(msg){
                alert(msg);
                actIndAlaUne.hide();
            }
        );
    }
this code worked fine before using tableViewRow.

2 Answers

Accepted Answer

Hi

Scrollableviews and tableviewrows do not really go well together. Could you explain a bit more about what you are trying to achieve so a better combination can be created as there is insufficient code to workout exactly what you are trying to achieve.

For example using a scrollview with a scrollableview is a much better combination in most cases, easier to manage and usually easier for the user.

— answered 10 months ago by Malcolm Hollingsworth
answer permalink
5 Comments
  • Hi

    Ok, that is good, you want the scrollview on the top of a table.

    var viewHeader = Ti.UI.createView({
        height: Ti.UI.SIZE,
        width: Ti.UI.FILL
    });
    viewHeader.add(your_scrollable_view_variable); // assumes you have already created in memory
     
    // use headerView property of the table
     
    var tbl = Ti.UI.createTableView({
      data: data, 
      headerView: viewHeader,
      height: Ti.UI.FILL,
      width: Ti.UI.FILL
    });
    This is only an example, you will need to blend your own code, but by using the the headerView you will greatly simplify the process.

    This assumes your scrollableview still works outside the table as you said it did.

    — commented 10 months ago by Malcolm Hollingsworth

  • Perfect !!! thanks :)

    — commented 10 months ago by Djamel ZAHAL

  • i hope it is the same solution on android ?

    — commented 10 months ago by Djamel ZAHAL

  • Show 2 more comments

to get the same interface. we can scroll all content.

https://dl.dropbox.com/u/84505667/ElKhabarMaquetteAccueil.png

Your Answer

Think you can help? Login to answer this question!