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开发者_StackOverflow中文版 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?).
viewDidLoad
only gets called the first time your view is initialized, not every time it's displayed. Functionality for refreshing the contents of views should go into viewWillAppear:.
精彩评论