ios - UILabel 未在详细 View 中显示

标签 ios swift uilabel

我目前正在学习 Swift,试图构建一个简单的 TableView Controller 和一个详细 View ,它显示主( TableView Controller )通过 segue 传递的数据。不确定我做错了什么,但我在详细 View 上看不到我的标签(我目前正在模拟器上测试)。我尝试将它打印到控制台,我可以看到标签的文本属性已设置。

知道为什么会发生这种情况吗?

详细 View Controller

override func viewDidLoad() {
    super.viewDidLoad()

    detailItem = ["title": "YES"]
    if let title: String = self.detailItem["title"] {
        if let label = self.titleLabel {
            label.text = title as String?
            println(title)
            println(label)
        }
    }
}

控制台输出

YES
<UILabel: 0x7fc731e2f220; frame = (0 -21; 42 21); text = 'YES'; opaque = NO; autoresize = RM+BM; layer = <_UILabelLayer: 0x7fc731e05ee0>>

enter image description here

最佳答案

Set width and height

查看我的截图并设置宽度和高度

关于ios - UILabel 未在详细 View 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29847826/

相关文章:

swift - "The file "MyApp.app "couldn' t被打开,因为你在 Xcode 6 Beta 4 中运行应用程序时没有 't have permission to view it"

ios - 以编程方式创建 UIView

ios - 如何在 PageViewController 滑动时更新 ViewController 中的 UIPageControl

ios - 无法在 Apple Watch 上安装 WatchKit 应用

iOS URL 请求。信号量问题

iphone - 与界面生成器和模拟器相比,为什么 UILabel 换行符在设备上的不同位置?

ios - 在 Xcode 5.1 中使用 XCTAssertEqual 比较 CGPoint 时出错

ios - 转至 Storyboard Reference 后出错

ios - 如何在自己的行上制作每个customLabel?

ios - 存储在序列化 View 中的子类 UILabel 不存储自定义变量