是否在iOS Swift中未正确加载Tableview数组?
我在一个聊天应用程序中工作。将发送方和接收方消息保存到firebase。我的问题尝试将数组消息加载到TableView时,消息未完全加载。它显示剩余消息的间隔 MainChatViewController.swift 这是我的截图: 我得到了正确的消息计数,但消息已完全加载 非常感谢您的帮助,请使用它。heightForRowAt表示单元格的高度,但必须检查约束。 并使用UITableViewDelegate来使用它是否在iOS Swift中未正确加载Tableview数组?,ios,swift,firebase,uitableview,Ios,Swift,Firebase,Uitableview,我在一个聊天应用程序中工作。将发送方和接收方消息保存到firebase。我的问题尝试将数组消息加载到TableView时,消息未完全加载。它显示剩余消息的间隔 MainChatViewController.swift 这是我的截图: 我得到了正确的消息计数,但消息已完全加载 非常感谢您的帮助,请使用它。heightForRowAt表示单元格的高度,但必须检查约束。 并使用UITableViewDelegate来使用它 func tableView(_ tableView: UITableView
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
你能发布tableView吗?tableView:UITableView,numberOfRowsInSection:Int->Int{method implementation?@claudio我已经在节中添加了numberOfRowsInSection。检查它,关于mainChatScreenTableViewCell方法是什么?这是用于任何标题还是其他内容?在mainChatScreenTableViewCell中,我使用了configCellmessage:Message函数@CodeChanger请为mainChatScreenTableViewCell添加代码我想我需要检查我的限制谢谢你的帮助answering@PvDev欢迎。如果我的答案对你来说是完全可用的,请将其添加为最喜欢的答案。这对其他人有帮助
import UIKit
import SwiftKeychainWrapper
import Firebase
import FirebaseStorage
import FirebaseDatabase
class mainChatScreenTableViewCell: UITableViewCell {
@IBOutlet weak var recievedMessageLbl: UILabel!
@IBOutlet weak var recievedMessageView: UIView!
@IBOutlet weak var sentMessageLbl: UILabel!
@IBOutlet weak var sentMessageView: UIView!
@IBOutlet var receivedTimeLabel: UILabel!
@IBOutlet var sentTimeLabel: UILabel!
@IBOutlet var likeOrUnlikeImageView: UIImageView!
@IBOutlet var errorImageView: UIImageView!
@IBOutlet var checkImage: UIImageView!
var message: Message!
var currentUser = KeychainWrapper.standard.string(forKey: "uid")
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
sentMessageView.layer.masksToBounds = true
recievedMessageView.layer.masksToBounds = true
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configCell(message: Message) {
self.message = message
print("message label::\(message.message.count)")
if message.sender == currentUser {
let time = message.receivedTimeStamp
let timeinterval : TimeInterval = time
let dateFromServer = NSDate(timeIntervalSince1970:timeinterval)
let formatter = DateFormatter()
formatter.calendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.ISO8601) as Calendar?
formatter.locale = NSLocale(localeIdentifier: "en_IN") as Locale
formatter.timeZone = NSTimeZone(name: "GMT+5:30") as TimeZone?
formatter.dateFormat = "h:mm a"
formatter.amSymbol = "AM"
formatter.pmSymbol = "PM"
let dateString: String = formatter.string(from: dateFromServer as Date)
print("dateString:::\(dateString)")
sentMessageView.isHidden = false
sentMessageView.layer.backgroundColor = UIColor.clear.cgColor
sentMessageLbl.text = " " + message.message
sentTimeLabel.text = " " + dateString
recievedMessageLbl.text = ""
recievedMessageLbl.isHidden = true
recievedMessageView.isHidden = true
} else {
let time = message.receivedTimeStamp
let timeinterval : TimeInterval = time
let dateFromServer = NSDate(timeIntervalSince1970:timeinterval)
let formatter = DateFormatter()
formatter.calendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.ISO8601) as Calendar?
formatter.locale = NSLocale(localeIdentifier: "en_IN") as Locale
formatter.timeZone = NSTimeZone(name: "GMT+5:30") as TimeZone?
formatter.dateFormat = "h:mm a"
formatter.amSymbol = "AM"
formatter.pmSymbol = "PM"
let dateString: String = formatter.string(from: dateFromServer as Date)
print("dateString:::\(dateString)")
sentMessageView.isHidden = true
sentMessageLbl.isHidden = true
sentMessageLbl.text = ""
recievedMessageLbl.text = " " + message.message
receivedTimeLabel.text = " " + dateString
recievedMessageLbl.isHidden = false
recievedMessageView.layer.backgroundColor = UIColor.clear.cgColor
}
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}