【发布时间】:2013-07-10 10:41:48
【问题描述】:
我将这个 calendar 用于 Titanium SDK。我需要做的是从服务器检索日期列表,如果日历上的日期有事件,则将图像添加到磁贴以表示该事件。我可以检索日期,但问题是日期并非特定于日期。例如,如果检索到的日期是 2012 年 8 月 12 日,那么这一天就等于 8。当我像这样在代码中设置图像时:
calendar.setImage(eventDay, 'path/to/image');
它设置每个月的第 8 天,而不仅仅是 12 月 8 日。
这是来自日历控制器的 setImage 函数:
exports.setImage = function(day,image, options) {
var _ref3;
if (options == null) {
options = {};
}
if (moment.isMoment()) {
day = day.date();
}
tile = (_ref3 = $.calendar) != null ? _ref3["" + day] : void 0;
if ((tile != null ? tile.date : void 0) != null) {
tile.remove(tile.children[0]);
_.extend(tile, {
_isEntry: true
}, options);
return tile.add(Ti.UI.createImageView({
image: image,
width: TILE_WIDTH,
height: TILE_WIDTH,
touchEnabled: true
}));
}
};
我尝试更改代码以接受月份和年份,然后将额外的变量添加到 _ref3 变量中,但这根本不起作用。
【问题讨论】:
-
尝试设置月份以及日期和年份
-
setImage方法只以天为参数
标签: java javascript ios momentjs titanium-alloy