我正在尝试实现从 5 秒倒计时的 NSTimer。但是我无法将 NSTimer 转换为从 5 到 0 的 UILabel。我应该从这里采取哪些步骤?
问候
MTPopupWindow.h
@class MTPopupWindow;
..............
@property (nonatomic, retain) NSTimer* timer;
@end
MTPopupWindow.m
@interface MTPopupWindow() <UIWebViewDelegate>
{
UIView* _dimView;
UIView* _bgView;
UIActivityIndicatorView* _loader;
NSTimer *timer;
}
@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 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:NO];
progress = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 200, 30)];
progress.textColor=[UIColor redColor];
progress.text = [NSString stringWithFormat:@"%@",timer];
[self addSubview: progress];
}
-(void)timerFireMethod:(NSTimer *)theTimer{
NSLog(@"bla bla time is out");
MTPopupWindowCloseButton* btnClose = [MTPopupWindowCloseButton buttonInView:self];
[btnClose addTarget:self action:@selector(closePopupWindow) forControlEvents:UIControlEventTouchUpInside];
}