我试图让我的视图使用重大位置更新刷新。位置管理器位于我的应用程序委托中,并且我尝试使用NSNotificationCenter来告诉视图控制器在用户更改位置时进行刷新。我不知道如何刷新以刷新视图。我现在有如下设置。我做了一个“视图控制器(刷新视图)”块,我认为刷新代码会发生。任何人都知道如何使这项工作?谢谢!重大位置更改的重新加载/刷新视图控制器(从应用程序委托)
应用代理(监听显著位置的变化):
- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation
*)newLocation fromLocation:(CLLocation *)oldLocation {
[[NSNotificationCenter defaultCenter] postNotificationName:@"refreshView" object:nil];
}
视图控制器(听NSNotificationCenter):
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshView:)
name:@"refreshView" object:nil];
}
视图控制器(刷新视图):
-(void)refreshView:(NSNotification *) notification {
//CODE TO REFRESH THE VIEW HERE
}
UIViewController * root = _window.rootViewController; UINavigationController * navController =(UINavigationController *)root; YourViewController * mycontroller =(YourViewController *)[[navController viewControllers] objectAtIndex:0]; [mycontroller reloadInputViews]; – iPatel 2013-02-25 09:14:06