swift3を使用して、ユーザーがピクチャまたは簡単なテキスト投稿の投稿を作成できるようにします。私はちょうどテキストの投稿を作成する場合を除いて、すべてうまく動作しています。セルのUIImageViewは、TableViewCellのスペースを埋めます。理想的には、ユーザーが単なるテキストの投稿を作成する場合、TableViewCellはUIImageViewではなく、キャプションラベルまですべてを含みます(画像参照)。これについてどうすればいいですか?TableViewCellのサイズを動的に変更して画像を表示する場合と表示しない場合
研究:私はその場合、あなたには、あなたがあなたのUIを作成するために、ストーリーボードを使用している参照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)
}