2012-01-17 99 views
1

我的應用程序中有一個ImageView,我使用http鏈接在ImageView中加載圖像。我需要每5分鐘更新/請求一次http鏈接,以查看是否有任何更改。我怎樣才能做到這一點?應用程序應每5分鐘要求一次服務器

回答

0

您可以使用定時器相同,可以調用特定功能每5分鐘。 Check this

+0

謝謝!我已經做到了,但我有一點疑問。我在viewDidLoad中完成了以下操作,其中NSTimer * currentTimer; NSTimer * currentTimer; currentTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(theActionMethod)userInfo:nil repeatats:YES]; 而theActionMethod是這樣 - (無效)theActionMethod { NSURL * IMAGEURL = [NSURL URLWithString:@「http://saypeople.com/wp-content/uploads/2011/11/apple-3d-logo -wallpaper.jpg「]; NSData * imageData = [NSData dataWithContentsOfURL:imageURL]; UIImage * _image = [UIImage imageWithData:imageData]; _imageview.image = _image; } – Roy 2012-01-17 07:14:35

+0

然後呢?什麼是問題? – Sarah 2012-01-17 07:16:52

+0

我在做正確的方式嗎?我的問題是它是否會檢查http鏈接?每當定時器調用theActiveMethod時,它會調用NSURL和NSData,..會導致任何內存問題? – Roy 2012-01-17 07:20:11

相關問題