【发布时间】:2016-07-26 13:02:30
【问题描述】:
我有一个只有一个主视图的简单视图应用程序。
当应用进入后台状态时,我试图在视图内的标签中显示更新的时间值。
场景是:
1 - 单视图应用程序项目
2 - 只有一个 View (ViewController) 带有一个 Label 来显示日期
3 - 在 AppDelegate:applicationWillEnterForeground 中获取当前时间
func applicationWillEnterForegound(application: UIAPplication){
var date:String = GetDate()
--> update View Label with date here
}
4 - 在 ViewController 上显示当前时间
我正在尝试使用委托,但问题是视图是应用程序中的最后一个可见元素,并且 viewDidLoad、viewWillAppear 等方法被调用一次。
【问题讨论】:
-
这种情况下最好使用NSNotification
标签: ios iphone swift uiviewcontroller