菜鸟教程小白 发表于 2022-12-13 06:38:01

ios - Storyboard中带有 UIButtons 的 PaintCode 2


                                            <p><p>我从 PaintCode 2 导出一个 StyleKit.h 文件。它有一个类方法:</p>

<pre><code>+ (UIImage*)myImage;
</code></pre>

<p>在我的 Storyboard中,我有一个 UIButton,我想将 UIControlStateNormal 的图像设置为 myImage。为此,我向 Storyboard 添加了一个通用对象,将对象的类设置为 StyleKit,然后创建从对象到 UIButton 的导出。这似乎是正确的;但是,当我构建运行时,出现错误。似乎 StyleKit 的实现会自动在 socket 的目标上调用 <code>setImage:</code> 。但是,您不会在 UIButton 上调用 <code>setImage:</code>,而是调用 <code>setImage:forState:</code>,因此它会引发无法识别的选择器异常。</p>

<p>您能否通过子类化 UIButton 并创建一个始终为 <code>UIControlStateNormal</code> 设置图像的 <code>setImage:</code> 方法在 Storyboard 中使用带有 UIButton 的 PaintCode 2?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>根据我的经验,PaintCode、Storyboard 和 Buttons 无法相处。您可以通过代码设置按钮的图像,但无法在 Storyboard 中连接它。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios -Storyboard中带有 UIButtons 的 PaintCode 2,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/29836136/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/29836136/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Storyboard中带有 UIButtons 的 PaintCode 2