我正在处理一个项目,但UITableViewCells出现问题,当我加载视图控制器然后滚动时,它们的行为很奇怪。
首先,当我加载视图控制器时,我会看到:
然后当我向下滚动和向上滚动时,我看到了(这就是我想要的):
有什么问题的想法吗? 这是代码的一部分
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.row {
case 0: //HEADER IMAGE
return 200.0
case 1: //VAMONOS BUTTON
return 195.0
case 2:
if(more) { //WITH SCALES
if(flightScales.count == 0) {
return 165.0
}
else {
return CGFloat(flightScales.count * 205) + 110.0
}
}
else { //WITHOUT SCALES
return 165.0
}
case 3:
if(accomodationMore) { //7LINE DESCRIPTION
return 435.0
}
else { //2LINE DESCRIPTION
return 180.0
}
default:
return 0.0
}
}
图像加载:
if let image = selectedFlight.image {
let requestUrl = url + "api/vuelo/imagen/" + image
headerCell.destinationImage.sd_setImage(with: URL(string: requestUrl), placeholderImage:UIImage(named: "icon-placeholder"))
}
else {
headerCell.destinationImage.image = UIImage(named: "icon-placeholder")
}
headerCell.initialize(destinationLabel: selectedFlight.title!, countryLabel: selectedFlight.desc!)
答案 0 :(得分:2)
尝试一下:
var timestamp = "Some Datetime String";
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
'SELECT * FROM root r WHERE r.dateadded > timestamp',
function (err, feed, options) {
var jstr = JSON.stringify(element);
data = JSON.parse(jstr);
console.log(data["value"]);
});