嗨,我正在实现弹出屏幕。实际上,我从一个站点找到了一个代码。但我不知道如何知道它是弹出屏幕还是视图。如果我们不使用自定义弹出窗口,我们确实喜欢这种模式:是的。但是当我们准备自定义弹出窗口时,如何知道它是弹出窗口还是屏幕?
看法
/FirstView Component Constructor
function SecondView2(data) {
//create object instance, a parasitic subclass of Observable
var dataArray =new Array();
dataArray[0]="naveee";
var wn = Ti.UI.createWindow({
backgroundColor:'red'
});
var self = Ti.UI.createView({
layout:"vertical",
height:300,
top:40
});
// Simplest list data items that can be displayed in a list view
var data = [
{ properties: { title: 'Row 1'} },
{ properties: { title: 'Row 2'} },
{ properties: { title: 'Row 3'} }
];
// Add the list data items to a section
var listSection = Titanium.UI.createListSection({items: data});
// Add the list section to a list view
var listView = Titanium.UI.createListView({sections: [listSection]});
var tableData = [ {title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'} ];
var table = Ti.UI.createTableView({
data: tableData
});
listView.addEventListener('itemclick', function(e){
//alert("ppp"+e.i);
//add();
var item = listSection.getItemAt(e.itemIndex);
var modal = require('ui/common/Third').modalWin;
var popupWin = new modal();
popupWin.open();
// alert(item.properties.title);
// alert(e.itemIndex);
});
self.add(listView);
wn.add(self);
return wn;
}
**pop up window**
exports.modalWin = function(){
//Popup win
var popupWin = Ti.UI.createWindow({
backgroundColor : 'black',
opacity : 0.5,
fullscreen : true,
id : 'popupWin'
});
//View that used to show the msg
var popupView = Ti.UI.createView({
width : 200,
height : 100,
backgroundColor : 'white',
borderRadius : 5,
borderColor : 'red',
borderWidth : 3
});
//A message label is added to the view
popupView.add(Ti.UI.createLabel({ width : 150, height : 'auto', top : 10 ,
text : 'This is Modal Window', backgroundColor : 'green',
font : { fontSize : 14, fontWeight : 'bold'}}));
popupWin.add(popupView);
/*Event to close the popup window*/
popupWin.addEventListener('click', function(e){
if(e.source.id != null){
popupWin.close();
}
});
return popupWin;
};