OGeek|极客世界-中国程序员成长平台

标题: ios - 钛 ScrollView [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 19:52
标题: ios - 钛 ScrollView

我在 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']);

请帮帮我! 谢谢!



Best Answer-推荐答案


尝试使用更多跨平台的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/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4