-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