2015-04-15 43 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

它解決了你的問題嗎? –