我成功创建了一个表,其行将根据开始日期和结束日期之间的天数生成。这是代码
NSURL* assetURL = [self.asset valueForProperty:ALAssetPropertyAssetURL];
NSDictionary* assetOptions = nil;
AVAsset* myAsset = [[AVURLAsset alloc] initWithURL:assetURL options:assetOptions];
self.imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:myAsset];
int duration = CMTimeGetSeconds([myAsset duration]);
for(int i = 0; i<duration; i++)
{
CGImageRef imgRef = [self.imageGenerator copyCGImageAtTime:CMTimeMake(i, duration) actualTime:NULL error:nil];
UIImage* thumbnail = [[UIImage alloc] initWithCGImage:imgRef scale:UIViewContentModeScaleAspectFit orientation:UIImageOrientationUp];
[thumbnailImages addObject:thumbnail];
}
我希望能够从开始日期开始自动递增日期值,因为生成行直到结束日期请帮助
答案 0 :(得分:0)
请参阅下面的解决方案,我希望我已了解您的要求。代码将currentDate定义为今天,并将其添加到每行的第一个表格单元格中,随着时间的推移递增一天。我希望它有所帮助。 (注意:我已经注释了几行来帮助我测试)
var tabled = document.getElementById("table_data");
var newRowContent = '';
//<button type="button" name="delete_row" class="glyphicon glyphicon-remove-sign" onclick="deleteRow(this)"></button> #delete button
//rows = table.insertRow(z);
var currentDate = new Date();
//if (tabled.rows.length > 0) {
$("#table_data tbody tr").remove();
for(i = 0; i < 5; i++){
var nextDate = new Date(currentDate);
nextDate.setDate(currentDate.getDate()+1);
newRowContent = '<tr><td>' + nextDate + '</td><td><input type="text" name="date" id="date" class="numbersOnly" onchange="vdateRange()" placeholder=""/></td><td><input type="text" name="reading1" class="numbersOnly" onkeypress="validate(event)" /></td><td><input type="text" name="reading2" class="numbersOnly" onkeypress="validate(event)" /></td><td><input type="text" name="reading3" class="numbersOnly" onkeypress="validate(event)" /></td><td><input type="text" name="remark"/></td></tr>';
$('#table_data tbody').append(newRowContent);
currentDate = nextDate;
}
//}