我想添加視圖時,我的滾動視圖,當它達到40%滾動。這是我這樣做的方式:鈦無限滾動:不工作
scrollView.add(//add first 10 initial containerView's);
var triggerScroll = true;
var scrollPercentage = 0;
scrollView.addEventListener('scroll', function(e) {
var devHeight = Ti.Platform.displayCaps.platformHeight;
var currPos = scrollView.contentOffset.y;
if(currPos > devHeight){
currPos = currPos - devHeight;
}
scrollPercentage = (currPos)/devHeight * 100;
if(scrollPercentage > 40 && triggerScroll){
triggerScroll = false;
var containerView = myapp.createMyView();
scrollView.add(containerView);
}
//reset scroll to true after the offset reaches end of the screen, so that the
//'scroll' event listener only gets called ONCE every time it crosses 40%
if(scrollPercentage > 101){
triggerScroll = true;
}
});
但它只是不工作。我正在嘗試在垂直滾動視圖中支持無限滾動。任何想法出了什麼問題?
does myapp.createMyView()返回具有set屬性的視圖嗎?或者只是一個空的視圖對象? –
設置屬性的視圖.. – sharath
從它的外觀來看,此代碼只會添加一個視圖。添加一個視圖後。 triggerScroll設置爲false,這將失敗if語句 –