我在 Titanium 中开发了一个应用程序。一个带有可滚动视图的代码。它在 Android 中工作,但在 IOS 中不工作,并且不显示错误消息。编码:
exports.imagescroller = function(images, imgWidth, imgHeight){
var imageCollection = images;
var window = Ti.UI.createWindow({
backgroundColor:'transparent',
});
if(imgWidth == null) {
imgWidth = "100%";
}
if(imgHeight == null) {
imgHeight = "100%";
}
var scrollGallery = Ti.UI.createScrollableView({
layout:'horizontal',
showHorizontalScrollIndicator:true,
showVerticalScrollIndicator:true,
});
var viewCollection = [];
for (var i = 0; i < imageCollection.length; i++) {
var innerView = Ti.UI.createView({
layout:'horizontal',
});
var item = Ti.UI.createImageView({
width : imgWidth,
height: imgHeight,
imageID:i,
defaultImage: imageCollection[0]
});
if (i < 3) {
item.image = imageCollection[i];
}
innerView.add(item);
viewCollection.push(innerView);
}
scrollGallery.addEventListener('scroll', function(e){
if (scrollGallery.currentPage < (imageCollection.length-1)) {
var nxt = scrollGallery.currentPage+1;
scrollGallery.views[nxt].children[0].image = imageCollection[nxt];
}
});
scrollGallery.views = viewCollection;
window.add(scrollGallery);
return window;
};
我在窗口中使用它:
var Scroller = require("imagescroller");
window = Scroller.imagescroller(allData['images']);
请帮我!谢谢!