私は共通のJSを使用してスクロール可能なメニューを作っています。チタンモバイル - ビュー上のaddEventListener
メニューのアイテムは、他の2つのコンポーネント: アイコンのimageViewと、このメニューのテキストのラベルを含むビューです。
コンパクトは奇妙で、アンドロイドとイオスのシミュレータでは同じではありません。
ラベル上または画像ビュー上でクリックが行われた場合、「uncaught TypeError:Can not Readプロパティ...」と表示されます。 iphoneの場合は、何も起動しません。
他の場所をクリックしても(画像が表示されていても)、画像やラボでは表示されません。ここで
コードである:
関数menuIcons(itemTab){
var menuMain = Ti.UI.createView({
layout : 'vertical',
backgroundColor : '#333333',
height : 125,
bottom : 10,
left : 10,
right : 10,
borderRadius : 5.0
});
var menuFirstLine = Ti.UI.createScrollView({
scrollType : 'horizontal',
contentHeight : 120,
contentWidth : 'auto',
layout : 'horizontal',
height : 120,
marginLeft : 5
});
var items = [];
var menuIconsItem = require('view/module/menuIconsItem');
for(var i in itemTab) {
var page = itemTab[i].page;
items[i] = new menuIconsItem(itemTab[i]);
(function(itemsEvent) {
itemsEvent.id = itemTab[i].id;
itemsEvent.addEventListener('click', function(e) {
Ti.App.fireEvent('main_menu_' + itemsEvent.id, {
id : e.source.id
});
})
})(items[i]);
menuFirstLine.add(items[i]);
}
menuMain.add(menuFirstLine);
return menuMain;
}
module.exportsはの=のmenuIcons。
及び必要とされるアイテムのコード(VAR menuIconsItem =必要とする( 'ビュー/モジュール/ menuIconsItem');):
機能menuIconsItem(アイテム){
// path for images on Android besoin de centraliser tout ca
var pathImages = '';
var itemImage = Ti.UI.createImageView({
image : item.imageLink,
width : 64,
height : 64,
top : 15
});
var itemLabel = Ti.UI.createLabel({
color : '#afafaf',
text : item.text,
font : {
textAlign : 'center'
},
height : 40,
top : 80
});
var menuItem = Ti.UI.createView({
width : 120,
height : 120,
backgroundColor : '#424242',
top : 5,
left : 5
});
menuItem.add(itemImage);
menuItem.add(itemLabel);
return menuItem;
}
module.exports = menuIconsItem;
あなたは恋人です、これは今完璧です! すばらしい助け、あまりにもありがとう! – geoffrey