我的iPhone应用是基于位置的应用。它通过NSURLConnection方法找到当前位置并显示自己的详细信息。现在我想在应用程序从后台变为活动状态时刷新此详细信息。我使用了刷新按钮,效果很好。因此,从-applicationDidBecomeActive:method调用刷新函数。它会成功刷新当前位置详细信息。但它并没有刷新其他地方的细节。如果我将当前位置更改为其他位置,则-applicationDidBecomeActive:调用refresh for current location only,视图屏幕中没有任何更改。我怎样才能解决这个问题,并且我想要刷新所有的地方呢?
委托方法:
-(void)applicationDidBecomeActive:(UIApplication *)application
{
[self.viewController refresh];//calls refresh method
}viewController方法:
-(void)refresh
{
NSLog(@"%@",self.placedetail.name);
[self displays:self.placedetail];
}Placedetails实例具有地点的经度和纬度,可以获取详细的位置信息。第一次是当前位置。
-(void)displays:(model *)place
{
self.placedetail=place;
NSString *strs=[@"http requst"];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:strs]];
NSLog(@"%@",request);
self.reqTimeZone=[NSURLConnection connectionWithRequest:request delegate:self];
[self.reqTimeZone start];
}我该如何解决这个问题?
发布于 2012-05-15 20:17:41
你应该在这个委托中写代码..
- (void)applicationWillEnterForeground:(UIApplication *)application{self.viewController刷新;
}
https://stackoverflow.com/questions/10596797
复制相似问题