菜鸟教程小白 发表于 2022-12-11 18:43:14

iOS Swift 3 框架 - 在 Storyboard 中无法访问


                                            <p><p>我在 swift 3 中创建了一个自定义框架来存储我的所有类、xib、 Controller 和 ui 控件。我可以生成它,但是当我将它添加到项目中时,我可以访问除 Storyboard 之外的所有内容。</p>

<p>例如,我有一个名为“MyCustomCell”的类,它是“MyCustomFramework”中“UITableViewCell”的子类。 </p>

<p>所以在我的 Storyboard上,当我想为 UITableViewCell 设置自定义类时,我在自定义类字段上写了“MyCustomCell”。但模块没有改变,“MyCustomFramework”不在列表中。</p>

<p>我不知道该怎么办。</p>

<p>我可以手动编写模块名称并且它可以工作,但是我可以访问我在我的类“MyCustomCell”中定义的@IBOutlet</p>

<p>这是我的类(class)“MyCustomCell”:</p>

<pre>导入 UIKit
进口基金会

打开类 MyCustomCell: UITableViewCell {

    @IBOutlet open var titleLabel: UILabel?
    @IBOutlet open var subtitleLabel: UILabel?

    打开函数设置(obj:MyObject){

      如果让标题 = obj.title {
            titleLabel?.text = 标题
      }

      if let subtitle = obj.subtitle {
            subtitleLabel?.text = 副标题
      }

    }

}
</pre>

<p>你有什么想法吗?</p>

<p>-- 编辑--</p>

<p>我发现我的最终项目无法访问所有 <strong>@IBOutlet</strong>、<strong>@IBInspectable</strong> 和其他类似内容。</p>

<p>而且我的模块也无法访问。我可以编译但不能将每个 @IB... 链接到 Storyboard 。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您必须在 Storyboard中将类设置为单元格的位置下方设置模块选项。</p>

<p>自定义类菜单:</p>

<p>类(class):你的类(class)
模块:框架</p>

<p>希望对您有所帮助! </p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS Swift 3 框架 - 在 Storyboard 中无法访问,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41849333/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41849333/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS Swift 3 框架 - 在 Storyboard 中无法访问