Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (3.4.0)
Viewing all articles
Browse latest Browse all 66

Change Window Orientation not changing!

$
0
0

// ************ CHECA SE O IOS É 7 OU 6 PRA BAIXO ****************
// Function to test if device is iOS 7 or later
function isiOS7Plus()
{
    // iOS-specific test
    if (Titanium.Platform.name == 'iPhone OS')
    {
        var version = Titanium.Platform.version.split(".");
        var major = parseInt(version[0],10);
 
        // Can only test this support on a 3.2+ device
        if (major >= 7)
        {
            return true;
        }
    }
    return false;
}
isiOS7Plus();
 
var iOS7 = isiOS7Plus();
var theTop = iOS7 ? 20 : 0;
var statusBar = iOS7 ? Titanium.UI.iPhone.StatusBar.LIGHT_CONTENT : Titanium.UI.iPhone.StatusBar.OPAQUE_BLACK;
 
var tamanhoX = Ti.Platform.displayCaps.platformWidth;
var tamanhoY = Ti.Platform.displayCaps.platformHeight;
////////////////////////////////////////////////
// CURRENT WINDOW
////////////////////////////////////////////////
var win = Ti.UI.currentWindow;
win.orientationModes = [ Ti.UI.PORTRAIT, Ti.UI.LANDSCAPE_RIGHT, Ti.UI.LANDSCAPE_LEFT ];
 
var nav = win.nav;
var drawer = win.drawer;
//var arrayBusca = win.array
Ti.Gesture.addEventListener( 'orientationchange', function(e){
    Ti.API.info( 'Portrait: ' + e.source.isPortrait() );
    Ti.API.info( 'Landscape: ' + e.source.isLandscape() );
});
////////////////////////////////////////////////
// TOP NAV
////////////////////////////////////////////////
var topNav = Ti.UI.createView({
    backgroundImage: 'imagens/rodape_bg.png',
    witdh: tamanhoX,
    height: 69,
    top: 0
});
win.add( topNav );
////////////////////
////////////////////////////////////////////////////////
////////////////////
var voltarBtn = Ti.UI.createButton({
    backgroundImage: 'imagens/Seta.png',
    width: 15,
    height: 25,
    left: '10%',
    zIndex: 5
});
topNav.add( voltarBtn );
 
var voltarBtnRect = Ti.UI.createButton({
    width: 60,
    height: 69,
    left: '3%',
    top: 0,
    zIndex: 6,
    backgroundColor: 'transparent',
    //opacity: 0.5
});
topNav.add( voltarBtnRect );
 
voltarBtnRect.addEventListener( 'click', function(){
    win.close();
});
////////////////////
////////////////////////////////////////////////////////
////////////////////
var rightBtn = Ti.UI.createButton({
    backgroundColor: 'transparent',
    backgroundImage: '/imagens/menuIcon.png',
    width: 30,
    height: 31,
    color: 'white',
    right: 30
});
topNav.add( rightBtn );
 
rightBtn.addEventListener( 'click', function(){
 
 
    if( drawer.isRightWindowOpen() == 0 ){
 
        // Move a Window central para o lado para a right Window aparecer
        drawer.toggleRightWindow();
 
    }else{
 
        // Volta a window central para o meio da tela
        drawer.toggleRightWindow();
 
    }
});
////////////////////////////////////////////////
// TABLEVIEW
////////////////////////////////////////////////
var data = [];
 
for( var i = 0; i < 10; i++ ){
    var row = Ti.UI.createTableViewRow({
        selectionStyle: Titanium.UI.iPhone.TableViewCellSelectionStyle.GRAY,
        height: 90,
        backgroundImage: 'imagens/fundo_consulta.png'
    });
 
    var logo = Ti.UI.createImageView({
        image: 'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/p320x320/10494856_10204330278201726_6670917489412805922_n.jpg?oh=ade3c4f73ba3b8aeedf02ca3f7685126&oe=54F01854&__gda__=1425504812_1f8c6901fa1fd0fff4d133a749725c54',//'imagens/referencia_logo.png',
        width: 75,
        heigh: 75,
        left: '5%'
    });
    row.add( logo );
 
    var nomeEst = Ti.UI.createLabel({
        text: 'Universo Positivo',
        color: '#666666',
        font:{
            fontSize: '16',
            fontWeight: 'bold'
        },
        left: '30%',
        right: '15%',
        top: '10%',
        height: 18
    });
    row.add( nomeEst );
 
    var endereco = Ti.UI.createLabel({
        text: 'Rua Lauro Oscar Diefenthaeller, 243 Bairro União - Estância Velha - RS (51)8187-2327',
        color: '#666666',
        font:{
            fontSize: '11'
        },
        left: '30%',
        right: '15%',
        top: '30%',
        bottom: '8%'
    });
    row.add( endereco );
 
    var detalhes = Ti.UI.createImageView({
        image: 'imagens/detalhes_btn.png',
        width: 30,
        height: 30,
        right: 10
    });
    row.add( detalhes );
 
    data.push( row );
 
}
 
var tableView = Ti.UI.createTableView({
    data: data,
    backgroundImage: '#eeeeee',
    top: 69
});
win.add( tableView );
 
tableView.addEventListener( 'click', function(e){
 
    var winDet = Ti.UI.createWindow({
        url: 'detalhes.js',
        backgroundColor: '#eeeeee',
        nav:nav,
        navBarHidden: true,
        statusBarStyle: statusBar,
        drawer: drawer,
        top: theTop
    });
    nav.openWindow( winDet );
});
////////////////////////////////////////////////
when I change my simulator orientation I get the listenerEvent for orientation changing but my layout not change with the window...

someone can help me here? I already add all orientations on tiapp.xml and I'm developing for iOS on Ti SDK 3.4.0

Thanks


Viewing all articles
Browse latest Browse all 66

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>