Close Window and Return to Home?
I've got a webview in a current window that I want to close and return to my apps.js "home" page but I cannot get it to work. Apps.js is in a parent (root) directory from where I currently am. Here's the code I'm currently working with. MUCH THANKS!
var win = Titanium.UI.currentWindow;
var webview = Titanium.UI.createWebView({url:'http://www.foo.com/About.html'});
var win = Titanium.UI.createWindow({title:
'About', barColor: '#4b4b4b'});
win.add(webview);
win.open({modal:true});
var close = Titanium.UI.createButton({
title:'close',
width:200,
height:40,
top:60
});
win.add(close);
close.addEventListener('click', function()
{
win.close();
});
win.open({url:'apps.js'});
4 Answers
-
close.addEventListener('click', function()
{
win.close();
});
win.open({url:'apps.js'});Change to…
close.addEventListener('click', function()
{
win.remove(webview);
}); -
Eldon…thanks for the quick reply…however…it throws me out of the app…
2010-04-01 10:47:27.872 Player[4956:207] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[TiUIWindowProxy removeFromSuperview]: unrecognized selector sent to instance 0x9502f00'
2010-04-01 10:47:27.872 Player[4956:207] Stack: (… -
Mark
You must not be using the latest 1.1.2
Remove did cause a crash in older versions
-
I don't think you should try to open different windows from one window object simultaneously.
Try this:
var win = Titanium.UI.createWindow({ title:'About', barColor: '#4b4b4b' }); var webview = Titanium.UI.createWebView({ url:'http://www.foo.com/About.html' }); win.add(webview); var close = Titanium.UI.createButton({ title:'close', width:200, height:40, top:60 }); win.add(close); close.addEventListener('click', function() { win.close(); }); win.open({modal:true}); // Why do you need to open this next window? // If it's meant to appear 'below' the modal window, // consider opening this window first. var win2 = Ti.UI.createWindow({url:'../apps.js'}); win2.open;
(I assume you're not using tabs - that would require
Ti.UI.currentTab.open(win2)
.)