嗨我正在实现弹出屏幕。实际上我从一个网站找到了一个代码。但是我不知道如何知道它是弹出屏幕还是视图。如果我们不使用自定义弹出窗口,我们确实喜欢 modal:true 。但是当我们准备自定义弹出窗口时如何知道弹出窗口或屏幕?
查看
/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;
};
答案 0 :(得分:0)
在可用性方面没有太大区别。但就编码而言,窗口的弹出效果是由modal:true关键字完成的。虽然在视图中你必须在设计上付出很多努力。您无法轻易地将其与客户端区分开来,即作为移动用户。