2015-04-15 97 views
1

我在单个.h文件中有两个@interface。我想访问secondary @interface中的方法。如何在.h文件中的辅助@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:方法

回答

1

@interface UIImageView (URL_Loading)

UIImageView类别因此它被加入2种的新方法。

导入headerUIImageView

实例中调用它:

[yourImageView setImageWithURL:url];

+0

它的工作表示感谢 –

1

只需导入类别你想用它取文件。

#import "UIImageView+URL_Loading.h" 

然后你可以访问它的方法。

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

非常感谢你。我所需要的只是导入它没有.h扩展名 –

+0

方法可以被调用。但它显示错误UIImageView + URL_Loading'文件未找到' –

+0

它解决了你的问题吗? –