I've gotten as far as setting the image (if it is available) but for some reason I cannot set the size of the image to the imageview (if it has an image or at least a cutout preview) I tried something along the lines of this
But as you can see, the image ends up taking up the whole cell not sure why...
Here's what the layout should look like... I tried to go for a aspect fill... but the end result comes to about the same...
Edit: added code, I forgot to add... that would help a lot right?
Setting the tabeview cells
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->UITableViewCell{
var cell:commentTableViewCell
if commentList[indexPath.row].cellType == 1{
//drink
cell = self.commentTableView.dequeueReusableCell(withIdentifier: "drink",for: indexPath) as! commentTableViewCell
cell.drinkName.text = commentList[indexPath.row].commentOwner
cell.drinkPrice.text = commentList[indexPath.row].comment
return cell
}
else{
//comment
cell = self.commentTableView.dequeueReusableCell(withIdentifier: "comment",for: indexPath) as! commentTableViewCell
cell.ownerTitle.text = commentList[indexPath.row].commentOwner
cell.commentContent.text = commentList[indexPath.row].comment
if commentList[indexPath.row].isFile{
//cell.imageView!.contentMode = UIViewContentMode.scaleAspectFill
cell.imageView!.image = commentList[indexPath.row].imageFile
}
else if !commentList[indexPath.row].isFile {
cell.imageView!.image = nil
cell.imageView!.removeFromSuperview()
}
return cell
}
}
The parsequery:
func getLocalComments(point:PFGeoPoint){
var temp = [CommentDetails]()
DispatchQueue.global(qos: .background).async {
let qComments = PFQuery(className: "UserCommentary")
let qDrinks = PFQuery(className: "venueDrinks")
if self.type == "House Parties"{
//Query the bars
qDrinks.whereKey("venueName", equalTo: self.id)
qDrinks.whereKey("venueID", equalTo: self.venueName)
qDrinks.addDescendingOrder("createdAt")
qComments.whereKey("venueID", equalTo: self.id)
qComments.whereKey("venueName", equalTo: self.venueName)
do{
let qReply1 = try qDrinks.findObjects()
if qReply1.count>0{
let comment:CommentDetails = CommentDetails.init(comm: "Test", ven: self.venueName, venId: self.id, owner: PFUser.current()!.username!, vote: 0)
var i = 0
while i < 2 {
let item = qReply1[i]
print(item)
comment.cellType = 2
i+=1
}
//temp.append(comment)
}
let qReply2 = try qComments.findObjects()
for item in qReply2{
let comment:CommentDetails = CommentDetails.init(comm: "Test", ven: self.venueName, venId: self.id, owner: PFUser.current()!.username!, vote: 0)
comment.commentOwner = item.object(forKey: "owner") as! String
comment.comment = item.object(forKey: "comment") as! String
comment.isFile = item.object(forKey: "image") as! Bool
if comment.isFile {
let dataPhoto:PFFile = item.object(forKey: "imgFile") as! PFFile
let imageData:NSData = try dataPhoto.getData()
let image:UIImage = UIImage(data:imageData as Data)!
comment.imageFile = image
comment.cellType = 2
}
temp.append(comment)
}
}
catch{
print(error)
}
}
DispatchQueue.main.async {
print(temp)
self.commentList.removeAll()
self.commentList = temp
self.commentTableView.reloadData()
}
}
}