ios - 我希望打印的值太长,无法打印 firebase 中的所有值

标签 ios swift firebase

enter image description here

我想从我的 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/

相关文章:

swift - 如何在 Swift 中从 url 下载视频?

ios - -[__NSCFNumber 计数] : unrecognised selector sent to instance 0x14539180 in Swift

javascript - Vuejs全局注册vuefire

ios - 自动布局约束错误

ios - Scrollview 如何与 Autolayout 一起工作,为什么设置底部垂直空间约束使其工作?

ios - Apns-告警自定义

ios - KMLViewer 问题

ios - 在 Collection View 中缓存图像

iOS Firebase Cloud Messaging 在应用程序关闭时获取数据

ios - 将 Firebase 数据库子级映射到 swift 3 对象