<i id='jkzYj'><tr id='jkzYj'><dt id='jkzYj'><q id='jkzYj'><span id='jkzYj'><b id='jkzYj'><form id='jkzYj'><ins id='jkzYj'></ins><ul id='jkzYj'></ul><sub id='jkzYj'></sub></form><legend id='jkzYj'></legend><bdo id='jkzYj'><pre id='jkzYj'><center id='jkzYj'></center></pre></bdo></b><th id='jkzYj'></th></span></q></dt></tr></i><div id='jkzYj'><tfoot id='jkzYj'></tfoot><dl id='jkzYj'><fieldset id='jkzYj'></fieldset></dl></div>
  • <legend id='jkzYj'><style id='jkzYj'><dir id='jkzYj'><q id='jkzYj'></q></dir></style></legend>
  • <tfoot id='jkzYj'></tfoot>

        <small id='jkzYj'></small><noframes id='jkzYj'>

        • <bdo id='jkzYj'></bdo><ul id='jkzYj'></ul>

        如何从同一个故事板访问 Objective-C 和 Swift 类?

        时间:2023-07-08

            <tfoot id='3LlSb'></tfoot>
              <tbody id='3LlSb'></tbody>
            <legend id='3LlSb'><style id='3LlSb'><dir id='3LlSb'><q id='3LlSb'></q></dir></style></legend>
          • <small id='3LlSb'></small><noframes id='3LlSb'>

              • <bdo id='3LlSb'></bdo><ul id='3LlSb'></ul>
                <i id='3LlSb'><tr id='3LlSb'><dt id='3LlSb'><q id='3LlSb'><span id='3LlSb'><b id='3LlSb'><form id='3LlSb'><ins id='3LlSb'></ins><ul id='3LlSb'></ul><sub id='3LlSb'></sub></form><legend id='3LlSb'></legend><bdo id='3LlSb'><pre id='3LlSb'><center id='3LlSb'></center></pre></bdo></b><th id='3LlSb'></th></span></q></dt></tr></i><div id='3LlSb'><tfoot id='3LlSb'></tfoot><dl id='3LlSb'><fieldset id='3LlSb'></fieldset></dl></div>

                1. 本文介绍了如何从同一个故事板访问 Objective-C 和 Swift 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经在 Swift 中实现了一个 UIButton 派生类(RoundButton),其余的仍在 Objective-C 中.如何在同一个 Storyboard 中同时访问基于 Objective-C 的类和基于 Swift 的类?

                  I have implemented one UIButton-derived class (RoundButton) in Swift and the rest is still in Objective-C. How do I access both Objective-C-based classes and Swift-based classes in the same storyboard?

                  您可以在 Storyboard 的 UIButton Custom Class - Class 字段中键入 RoundButton,但 iOS 会给出以下警告运行时:

                  You can type RoundButton in a UIButton Custom Class - Class field in a Storyboard, but iOS gives the following warning runtime:

                  Unknown class RoundButton in Interface Builder file.
                  

                  推荐答案

                  看来Xcode 6.0 (6A215l) 需要将Storyboard 文件升级到更新版本才能访问Swift 类.

                  It seems that Xcode 6.0 (6A215l) needs to upgrade the Storyboard file to a newer version before it can access Swift classes.

                  如果您将 Objective-C 类替换为同名的 Swift 类,则需要打开 Storyboard,编辑自定义类的名称(如删除最后一个字母),保存 Storyboard,然后重命名该类背部.这将强制 Storyboard 文件升级到更新的版本,并且新的 Xcode 正确地编写自定义类键,如下所示:

                  If you replaced an Objective-C class with a Swift class with the same name, you need to open the Storyboard, edit the name of the custom class (like remove the last letter), save the Storyboard and then rename the class back. This will force the Storyboard file to be upgraded to a newer version, and the new Xcode to correctly write the custom class key like this:

                  版本信息差异:

                  UIButton 自定义类定义差异:

                  UIButton custom class definition diff:

                  在 Storyboard 文件中进行这些更改后,警告似乎消失了,并且使用了正确的自定义类.

                  After these changes in the Storyboard file the warning seems to disappear and the correct custom class is used.

                  这篇关于如何从同一个故事板访问 Objective-C 和 Swift 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:裁剪的 UIButton 标题 下一篇:我的自定义按钮在 iCarousel iOS 中没有得到点击?

                  相关文章

                  <tfoot id='5TaaJ'></tfoot>

                2. <legend id='5TaaJ'><style id='5TaaJ'><dir id='5TaaJ'><q id='5TaaJ'></q></dir></style></legend>
                3. <i id='5TaaJ'><tr id='5TaaJ'><dt id='5TaaJ'><q id='5TaaJ'><span id='5TaaJ'><b id='5TaaJ'><form id='5TaaJ'><ins id='5TaaJ'></ins><ul id='5TaaJ'></ul><sub id='5TaaJ'></sub></form><legend id='5TaaJ'></legend><bdo id='5TaaJ'><pre id='5TaaJ'><center id='5TaaJ'></center></pre></bdo></b><th id='5TaaJ'></th></span></q></dt></tr></i><div id='5TaaJ'><tfoot id='5TaaJ'></tfoot><dl id='5TaaJ'><fieldset id='5TaaJ'></fieldset></dl></div>
                    <bdo id='5TaaJ'></bdo><ul id='5TaaJ'></ul>

                  <small id='5TaaJ'></small><noframes id='5TaaJ'>