我想从我的 firebase 打印出哈希值,但由于屏幕尺寸,它无法全部打印出来。怎么解决呢?
func loadHashData() {
guard let uid = Auth.auth().currentUser?.uid else { return }
Database.database().reference().child("users").child(uid).child("hashedpdf").observeSingleEvent(of: .value) { (snapshot) in
guard let hashedpdf = snapshot.value as? String else { return }
self.hashLabel.text = "The hashed values of chosen pdf is: \(hashedpdf)"
UIView.animate(withDuration: 0.1, animations: {
self.hashLabel.alpha = 1
})
}
}
最佳答案
使您的 UILabel
仅具有顶部、左侧和右侧的约束(也称为无高度约束),然后:
<#UILabel#>.numberOfLines = 0
<#UILabel#>.lineBreakMode = .byWordWrapping
不确定您的完整代码详细信息,但您可能还需要:
<#UILabel#>.sizeToFit()
<#UILabel#>.layoutIfNeeded()
<小时/>
请注意,这与标签创建更相关,而不是与 Firebase 请求(您提供的代码)相关。
关于ios - 我希望打印的值太长,无法打印 firebase 中的所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57360425/