-1
我需要显示在背景中在分钟的WebRequest加载时间的计时器:秒format.When所述的WebRequest成功加载定时器具有stop.My代码是在这里:如何在xcode中显示webrequest加载时间的NSTimer?
@interface TimerWithWebrequestViewController : UIViewController {
IBOutlet UIWebView *webView;
IBOutlet UILabel *lbl;
int mainInt;
NSTimer *randomMain;
}
@property(nonatomic,retain) UIWebView *webView;
-(void)upDate;
@end
@implementation TimerWithWebrequestViewController
@synthesize webView;
-(void)viewDidLoad
{
NSString *urlAdd = @"http://www.google.com";
NSURL *url = [NSURL URLWithString:urlAdd];
NSURLRequest *reqObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:reqObj];
[self performSelectorInBackground:@selector (upDate) withObject:nil];
}
-(void)upDate
{
mainInt = 0;
randomMain = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(randomMainVoid) userInfo:nil repeats:YES];
}
-(void)randomMainVoid{
mainInt += 1;
lbl.text = [NSString stringWithFormat:@"%d",mainInt];
}
不是问题。 – Nick 2010-09-20 06:07:30
请勿在堆栈溢出中使用“代码”标签。改为使用“101010”按钮来格式化代码。 – 2010-09-20 06:16:45