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



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

我的头文件的名称是 MyImage.h

@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

谁能告诉我如何调用setImageWithURL:方法

@interface UIImageView (URL_Loading)

是一类UIImageView,因此它添加了 2 个新方法。

导入header并在UIImageView中调用它

例:

[yourImageView setImageWithURL:url];

只需在要使用的任何文件中导入类别即可。

#import "UIImageView+URL_Loading.h"

然后您可以访问其方法。

UIImageView *imgView = [UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[imgView setImageWithURL:url];

相关内容

最新更新