Frage

I am trying to implement a NSTimer counting down from 5 seconds. But I am getting the message "No known class method for selector scheduledTimerWithTimeInterval:target:selector:userInfo:repeats....." What am I missing? If you look at the bottom of MTPopupWindow.m in method -void(showInView) you will find the code where the error emerges.

Regards

MTPopupWindow.h

@class MTPopupWindow;

@protocol MTPopupWindowDelegate <NSObject>
@optional
- (void) willShowMTPopupWindow:(MTPopupWindow*)sender;
- (void) didShowMTPopupWindow:(MTPopupWindow*)sender;
- (void) willCloseMTPopupWindow:(MTPopupWindow*)sender;
- (void) didCloseMTPopupWindow:(MTPopupWindow*)sender;
@end

@interface MTPopupWindow : UIView

+(MTPopupWindow*)showWindowWithHTMLFile:(NSString*)fileName;
+(MTPopupWindow*)showWindowWithHTMLFile:(NSString*)fileName insideView:(UIView*)view;
- (void)timerFireMethod; 
-(void)showInView:(UIView*)v;
+(void)setWindowMargin:(CGSize)margin;

@property (strong, nonatomic) NSString* fileName;
@property (strong, nonatomic) UIWebView* webView;
@property (weak, nonatomic) id <MTPopupWindowDelegate> delegate;
@property (nonatomic) BOOL usesSafari;
@property (nonatomic, retain) NSTimer* timer;
@end

MTPopupWindow.m

#import "MTPopupWindow.h"
#import "QuartzCore/QuartzCore.h"
#define kCloseBtnDiameter 30
#define kDefaultMargin 18
static CGSize kWindowMarginSize;

@interface MTPopupWindow() <UIWebViewDelegate>
{
UIView* _dimView;
UIView* _bgView;
UIActivityIndicatorView* _loader;
NSTimer *timer;
}
@end

@interface MTPopupWindowCloseButton : UIButton
+ (id)buttonInView:(UIView*)v;
@end

@interface UIView(MTPopupWindowLayoutShortcuts)
-(void)replaceConstraint:(NSLayoutConstraint*)c;
-(void)layoutCenterInView:(UIView*)v;
-(void)layoutInView:(UIView*)v setSize:(CGSize)s;
-(void)layoutMaximizeInView:(UIView*)v withInset:(float)inset;
-(void)layoutMaximizeInView:(UIView*)v withInsetSize:(CGSize)insetSize;
@end

@implementation MTPopupWindow

@synthesize fileName = _fileName;
@synthesize webView = _webView;
@synthesize usesSafari = _usesSafari;
@synthesize delegate = _delegate;
@synthesize timer;

-(void)showInView:(UIView*)v
{
.......
self.timer = [NSTimer scheduledTimerWithTimeInterval:5 taget:self selector:@selector(timerFireMethod:) userInfo:nil repeats:NO];  

<---No class method for selector scheduledTimerWithTimeInterval:target:selector....

}

-(void)timerFireMethod:(NSTimer *)theTimer{

NSLog(@"bla bla time is out");
MTPopupWindowCloseButton* btnClose = [MTPopupWindowCloseButton buttonInView:self];
[btnClose addTarget:self action:@selector(closePopupWindow) forControlEvents:UIControlEventTouchUpInside];

}
War es hilfreich?

Lösung

You misspelled 'target' as 'taget' in your method call. Do:

self.timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:NO];

Instead.

Andere Tipps

The method in .h file is: - (void)timerFireMethod; But at the selector is: timerFireMethod: With ":" at the end but there is no parameter, that is the reason.

Your definition between h file and m file is not consistence. Please correct the timerFireMethod method.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top