0

Have a problem I don't fully understand where I've gone wrong. I'm using NSDate to fill two labels with the date and time. That all runs well, as soon as the user clicks on the app it retrieves the dates and times correctly.

However, if I come out of the app and go to the home screen then go back, it doesn't reload with the date/ time as I would have expected. (I've only been using xcode for the past month so my apologies if I've missed something obviously fundamental.)

I've searched online but just getting further confused. Previously I used the same code in a button and on each click it did return a new date and time as expected - thought it would do the same when put in 'viewdidload'. Wondering if this is only a simulator thing?

Also I've tried releasing the labels/formatter:

[labelDate release];
[dateformatter release;] 

But seems to ignore these (although heard NSDate auto-releases?).

4

1 回答 1

0

viewDidLoad仅在第一次初始化视图时调用,而不是每次显示时调用。刷新视图内容的功能应该进入viewWillAppear:

于 2010-12-10T05:13:09.930 回答