swift3을 사용하여 사용자가 그림이나 간단한 텍스트 게시물을 작성할 수있게하고 싶습니다. 전 단지 텍스트의 게시물을 만들 때를 제외하고는 모든 것이 잘 작동합니다. 셀의 UIImageView가 TableViewCell의 공간을 채 웁니다. 이상적으로, 사용자가 단지 텍스트의 포스트를 만들면 TableViewCell은 UIImageView가 아닌 캡션 레이블까지 모든 것을 포함합니다 (이미지 참조). 이것에 대해 어떻게 생각하세요.TableViewCell의 이미지 크기를 동적으로 조정하십시오.
연구 :https://www.youtube.com/watch?v=zAWO9rldyUE, https://www.youtube.com/watch?v=TEMUOaamcDA, https://www.raywenderlich.com/129059/self-sizing-table-view-cells
현재 코드
func configureCell(post: Post){
self.post = post
likesRef = FriendSystem.system.CURRENT_USER_REF.child("likes").child(post.postID)
userRef = FriendSystem.system.USER_REF.child(post.userID).child("profile")
self.captionText.text = post.caption
self.likesLbl.text = "\(post.likes)"
self.endDate = Date(timeIntervalSince1970: TimeInterval(post.time))
userRef.observeSingleEvent(of: .value, with: { (snapshot) in
let snap = snapshot.value as? Dictionary<String, Any>
self.currentUser = MainUser(uid: post.userID, userData: snap!)
self.userNameLbl.text = self.currentUser.username
if let profileImg = self.currentUser.profileImage {
self.profileImg.loadImageUsingCache(urlString: profileImg)
} else {
self.profileImg.image = #imageLiteral(resourceName: "requests_icon")
}
})
// This is where I belive I need to determine wether or not the cell should have an image or not.
if let postImg = post.imageUrl {
self.postImg.loadImageUsingCache(urlString: postImg)
}