Titanium Mobile:加载第一个窗口后应用程序崩溃
我已经开始了一个新的钛合金移动项目(第一次!)。我有一个文件 main.js,其中有一个选项卡组和 2 个链接到两个窗口的选项卡。我的第一个选项卡似乎加载得很好,但之后的所有选项卡似乎都崩溃了。我无法单击列表项或触发按钮单击事件。我的第二个选项卡不起作用。但并非总是如此。一半的时候还好,另一半的时候就崩溃了。这是我的代码:
app.js:
Titanium.UI.setBackgroundColor('#fff');
var main = Ti.UI.createWindow({
url:'main_windows/main.js',
height:Ti.Platform.displayCaps.platformHeight,
width:Ti.Platform.displayCaps.platformWidth,
fullscreen: true,
navBarHidden: false
});
main.open();
main.js:
var win = Ti.UI.currentWindow;
var appointments = Titanium.UI.createWindow({});
appointments.url = 'appointments.js';
var quotes = Titanium.UI.createWindow({});
quotes.url = 'quotes.js';
var tabAppointments = Titanium.UI.createTab({
icon:'../KS_nav_views.png',
title:'Appointments',
window:appointments
});
var tabQuotes = Titanium.UI.createTab({
icon:'../KS_nav_views.png',
title:'Quotes',
window:quotes
});
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// add tabs
//
tabGroup.addTab(tabAppointments);
tabGroup.addTab(tabQuotes);
// open tab group
tabGroup.open();
当我启动我的应用程序时,会加载约会窗口。但是,当我单击“引号”选项卡或列表项之一时,什么也没有发生。
这是我的 Appointments.js 文件:
var win = Ti.UI.currentWindow;
win.backgroundColor = '#fff';
win.title = 'Appointments';
var data = [
{title:'Billy Jones', hasChild:true},
{title:'Adrian Hart', hasChild:true},
{title:'Sid Vel', hasChild:true},
{title:'Andrew Coats', hasChild:true}
];
// create table view
var tableview = Titanium.UI.createTableView({
data:data
});
win.add(tableview);
我的quotes.js 文件与上面的文件相同,但窗口标题不同。
就像我说的,有时每个似乎都能工作,然后我重建代码,它就不再工作了。
任何帮助非常感谢!
比利
I've started a new titanium mobile project (1st time!). I have a file main.js with a tab group and 2 tabs linking to two windows. My first tabs seems to load up fine but everything after that seems to crash. I can't click on a list item or fire a buttons click event. My second tab doesn't work. It's not all the time though. Half the time it's fine, the other half it crasehs. Here is my code:
app.js:
Titanium.UI.setBackgroundColor('#fff');
var main = Ti.UI.createWindow({
url:'main_windows/main.js',
height:Ti.Platform.displayCaps.platformHeight,
width:Ti.Platform.displayCaps.platformWidth,
fullscreen: true,
navBarHidden: false
});
main.open();
main.js:
var win = Ti.UI.currentWindow;
var appointments = Titanium.UI.createWindow({});
appointments.url = 'appointments.js';
var quotes = Titanium.UI.createWindow({});
quotes.url = 'quotes.js';
var tabAppointments = Titanium.UI.createTab({
icon:'../KS_nav_views.png',
title:'Appointments',
window:appointments
});
var tabQuotes = Titanium.UI.createTab({
icon:'../KS_nav_views.png',
title:'Quotes',
window:quotes
});
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// add tabs
//
tabGroup.addTab(tabAppointments);
tabGroup.addTab(tabQuotes);
// open tab group
tabGroup.open();
When I launch my app the appointments window is loaded. But when I click the quotes tab or one of the list items nothing happens.
Here is my appointments.js file:
var win = Ti.UI.currentWindow;
win.backgroundColor = '#fff';
win.title = 'Appointments';
var data = [
{title:'Billy Jones', hasChild:true},
{title:'Adrian Hart', hasChild:true},
{title:'Sid Vel', hasChild:true},
{title:'Andrew Coats', hasChild:true}
];
// create table view
var tableview = Titanium.UI.createTableView({
data:data
});
win.add(tableview);
My quotes.js file is identical to the above but with a different window title.
Like I said sometimes the every seems to work then I rebuild the code and it's not working again.
Any help most appreciated!
Billy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将 main.js 更改为
有帮助吗?
what about changing main.js to
does that help?
您的列表视图上没有单击事件处理程序,因此这就是单击列表时没有任何反应的原因。
所有文件位于哪里?我注意到你在名为
main_windows
的目录中有一些?确保通过 URL 创建窗口时路径设置正确。您可以通过将所有文件移动到同一目录来检查是否是 URL 路径问题,然后查看是否有效you do not have a click event handler on your list view, so that is why nothing is happening when you click the list.
where are all of the files located? I noticed you have some in a directory called
main_windows
? make sure you have the paths set correctly when creating the windows through URLs. You check if it is a URL path problem by moving all files to the same directory and then see if it works首先尝试这个...
将您的图标路径替换为类似的路径,然后编译并检查,您不需要给出路径.../将从应用程序的根目录获取...
根据您的声明,代码有时有效,有时无效。删除构建文件夹中 Android 文件夹的内容,然后尝试编译,这是因为一些缓存问题以及您正在使用的钛的版本。
从 main.js 文件中删除
var win = Ti.UI.currentWindow;
...让我知道其中有人是否有效,这可能是其中的任何问题,如果您的问题仍然存在...请在此处发表评论。
Try this first...
Replace your icon path to something like this and compile and check, you don't need to give the path... / would take from the root of your app...
According to your statement, the code works some times and does not some times. Delete your content of Android folder inside build folder and then try to compile, this is because of some caching issue and btw which version of titanium you are using.
Remove
var win = Ti.UI.currentWindow;
from main.js file...Let me know if anyone of them worked, it could be any issue among them and if your issue still persists... please do comment here back.