Objective c 为什么更改时区后NSTimeZone返回旧时区
我最小化以放置我的应用程序,然后更改时区,然后打开应用程序NSTimeZone返回时区的旧值。 如果我最小化到托盘并再次打开时区,则返回新值。我怎样才能修好它Objective c 为什么更改时区后NSTimeZone返回旧时区,objective-c,nstimezone,Objective C,Nstimezone,我最小化以放置我的应用程序,然后更改时区,然后打开应用程序NSTimeZone返回时区的旧值。 如果我最小化到托盘并再次打开时区,则返回新值。我怎样才能修好它 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadVC)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadVC)
name:UIApplicationWillEnterForegroundNotification
object:nil];
-(void) reloadVC{
NSTimeZone *currentTimeZone = [NSTimeZone localTimeZone];
NSLog(@"%@", currentTimeZone);
}
如果进入前台时您计划做的只是捕捉时区变化,请遵守此通知: 当您的应用程序进入前台时,此通知将排队等待处理,因此您不需要单独的观察者进入前台
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadVC)
name:NSSystemTimeZoneDidChangeNotification
object:nil];
-(void) reloadVC{
NSTimeZone *currentTimeZone = [NSTimeZone localTimeZone];
NSLog(@"%@", currentTimeZone);
}