2012-01-17 91 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

相关问题