菜鸟教程小白 发表于 2022-12-12 15:04:24

ios - 如何在.h文件的辅助@interface中调用方法


                                            <p><p>我在单个 .h 文件中有两个 @interface。我想访问辅助@interface 中的方法。</p>

<p>我的头文件名为 MyImage.h</p>

<pre><code>@interface MyImage : NSObject

- (void)addImage:(UIImage *)image forName:(NSString*)fileName;

- (void)clearImageCache;

@end

@interface UIImageView (URL_Loading)

- (void)setImageWithURL:(NSURL *)url;

- (void)setImageWithURL:(NSURL *)url
   placeholderAsSpinner:(BOOL)spinnerEnabled;

@end
</code></pre>

<p>谁能告诉我如何调用 setImageWithURL: 方法</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p><strong><code>@interface UIImageView (URL_Loading)</code></strong> </p>

<p>是<code>UIImageView</code>的一个类别,所以它增加了2个新方法。</p>

<p>导入 <code>header</code> 并在 <code>UIImageView</code></p> 中调用它

<p>例子:</p>

<p><strong><code>;</code></strong> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在.h文件的辅助@interface中调用方法,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/29652515/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/29652515/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在.h文件的辅助@interface中调用方法