gpt4 book ai didi

ios - Titanium scrollableView

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:35:58 24 4
gpt4 key购买 nike

我在 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 - Titanium scrollableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22195162/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com