我在 Titanium 中开发了一个应用程序。一个带有可 ScrollView 的代码。 它在 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']);
请帮帮我! 谢谢!
尝试使用更多跨平台的scrollend
事件:
scrollGallery.addEventListener('scrollend', function(e){
.......
});
还可以尝试为 ScrollableView 指定明确的宽度和高度,以排除这种情况:
var scrollGallery = Ti.UI.createScrollableView({
layout:'horizontal',
showHorizontalScrollIndicator:true,
showVerticalScrollIndicator:true,
width : "100%"
height : "100%"
});
关于ios - 钛 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22195162/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |