문제

I added a category to UIView to hold some transition helper methods. The methods are all working; however, I get compiler warnings:

warning: 'UIButton' may not respond to '-fadeOutWithDuration:'

My "UIView+Trans.h" file looks like this:

@interface UIImage (trans)
- (void) fadeOutWithDuration:(CGFloat)duration;
@end

My "UIView+Trans.m" file looks like this:

#import <QuartzCore/QuartzCore.h>
#import "UIView+Trans.h"

@implementation UIView (trans)
- (void) fadeOutWithDuration:(CGFloat) duration {
    //...
}
@end

And I'm calling the method like this: (and have #import "UIView+Trans.h" at the top of each file that uses the category method.) I've also tried casting the UIButton* to a UIView*.

[self.myButton fadeOutWithDuration:kFadeOutDuration];

I've used the "NSString+Reverse" example from this Categories Example article successfully in the same project and without the pesky warnings.

도움이 되었습니까?

해결책

In your header file, you've declared the category on UIImage not UIView.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top