gpt4 book ai didi

ios - 如何在午夜后重置应用程序

转载 作者:行者123 更新时间:2023-11-29 01:55:56 25 4
gpt4 key购买 nike

我正在通过使用 CMPedometer 类开发 Pedometer 应用程序。它工作正常,我通过内置应用程序- HealthKit 交叉检查了该值。然而,当我今天早上醒来时,我仍然看到昨天的值(value)。

然后我关闭了应用程序并再次打开它,然后它显示了今天的值(value)。

我的问题是如何处理这个问题?

最佳答案

您可以在 ViewController 或 Model 中使用 applicationWillEnterForeground Delegate ...(如果你想在特定的 VC 或模型中处理,你必须注册它)或者你可以从你的 appDelegate 中使用这个委托(delegate)

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateData) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]]; // Dont forgot about removeObserve 

-(void)updateData{

[[CMPedometer sharedInstance]update]; // update your data

// now you should update Your UI

[self.tableView reloadData];}

关于ios - 如何在午夜后重置应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30850940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com