【问题标题】:Nib file designing in Xcode 9 using IB使用 IB 在 Xcode 9 中设计 Nib 文件
【发布时间】:2019-02-06 03:38:31
【问题描述】:

我正在制作 ios 应用程序,并且我是 iOS 的初学者。我正在制作一个应用程序,在此我正在尝试制作自定义 tableview 单元格。

为此,我添加了一个 cocoa touch 类,并检查以创建它的 nib 文件。

现在在 IB 中,我将 UiLabel、Buttons 等视图放入其中,使其在 IB 中的高度更大。但这不是更新视图。我在视图中看不到任何东西。

我想直观地看到它,以便我可以设置自动布局约束 通过IB。有没有人注意到这件事?为什么IB的观点不 更新?我已经启动了我的mac。但它没有帮助。任何建议 请问?

注意:我使用的是 Xcode 9.2

【问题讨论】:

    标签: ios interface-builder xcode9.2


    【解决方案1】:

    您是否已将您的 nib 文件注册为 UITableViewCell?首先,您需要在已删除 tableView 出口的类的 viewDidLoad 中注册您的 nib 文件。

    override func viewDidLoad() {
            super.viewDidLoad()
            tableView.registerNib(UINib(nibName: "CustomOneCell", bundle: nil), forCellReuseIdentifier: "CustomCellOne")
        }
    

    在此之后,转到您的 tableView 代表,

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
            let cell = tableView.dequeueReusableCellWithIdentifier("CustomCellOne", forIndexPath: indexPath) as! CustomOneCell
            return cell
        }
    

    确保分配 tableview 委托和数据源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-16
      • 1970-01-01
      • 2013-12-24
      • 2015-05-26
      • 1970-01-01
      • 1970-01-01
      • 2015-06-07
      • 1970-01-01
      相关资源
      最近更新 更多