Reload screen on rotate...
Ok folks…
So I need to somehow refresh the screen on rotate (iPhone). I'm using percentages for my widths - but that's not enough as the screen doesn't actually recalculate the widths when the hardware is rotated.
The parent to this page has an orientationchange event listener. That seems like a good place to do the reFresh… but I don't know how to do it.
I'm pretty sure I had this working at one point on an ipad app with no effort at all… I just set the width to some math based on the window width and it worked. But it doesn't seem to want to do that here.
My code is below.
var win = Titanium.UI.currentWindow;
var scrollView1 = Titanium.UI.createScrollView({
contentWidth:'auto',
contentHeight:'auto',
showVerticalScrollIndicator:true,
showHorizontalScrollIndicator:true,
layout:'vertical'
});
var padding = 10;
var view_itemtitle = Ti.UI.createView({
top:padding,
backgroundColor:'#ffffff',
borderRadius:10,
width: '90%',
height:'auto'
});
var label_itemtitle = Titanium.UI.createLabel({
top:padding,
text:win.itemtitle + 'nnn',
color:'#003399',
width: '90%',
font:{fontSize:18,fontWeight:'bold',fontFamily:'Helvetica Neue'},
height: 'auto'
});
view_itemtitle.add(label_itemtitle);
scrollView1.add(view_itemtitle);
var view_itemdesc = Ti.UI.createView({
top:padding,
backgroundColor:'#ffffff',
borderRadius:10,
width: '90%',
height:'auto'
});
var label_itemdesc = Titanium.UI.createLabel({
top:padding,
text:win.itemdesc + 'nnn',
color:'#000000',
width: '90%',
font:{fontSize:14,fontWeight:'normal',fontFamily:'Helvetica Neue'},
height: 'auto'
});
view_itemdesc.add(label_itemdesc);
scrollView1.add(view_itemdesc);
win.add(scrollView1);
7 Answers
-
You don't need to reload, you need to reset the percentages.
-
Try adding this at the bottom of your code to detect the orientation change
Ti.Gesture.addEventListener('orientationchange',function(e){ Ti.API.info('the orientation changed to '+e.orientation); // now do stuff... refresh etc.. });
-
Yeah I already have that.
As I said:"The parent to this page has an orientationchange event listener. That seems like a good place to do the reFresh… but I don't know how to do it"
I can't figure out the commands to put there that would cause the page to refresh.
I'd love something like
win.reLoad();
but there seems to be no such functionality.
How can I get the screen to refresh itself?Thanks!
-
Anyone?
Need to force a screen to fresh.
Any ideas?
-
{removed}
Duplicate answer.
-
Doug,
I am trying to do the same thing as you were, did you ever find an answer?Thanks!
-
Doug,
I am trying to do the same thing as you were, did you ever find an answer?Thanks!