I have an UIImageView object in one of my viewController view that is preloaded with a picture of the wheel. However, the rotation of the wheel is determined by the time of day. So when the program launches, I like the wheel to be initialized by the correct rotation base on the current time. I tried to do this with a rotation in the viewDidLoad method of the controller. While this works, one can visibly see the initial position and the switch to new position based on time.
I like the initialization to be invisible, that is the initialization to occur before the view is loaded. Where should I do that?
A view controller’s view will be loaded whenever the controller’s
viewproperty is accessed, and-viewDidLoadwill be called at that point. Putting your code to set up the view in-viewDidLoadis the correct thing to do. You can’t initialize the view before it’s loaded because it doesn’t exist until it’s loaded, but you should be able to set it up before it’s displayed.If you’re not doing anything in your
-viewDidLoadthat would cause the wheel setup to be deferred to a later point in time, then you might try to load the view controller’s view a little earlier. For example, you could implement-prepareForSegue:sender:in your view controller so that it accesses theviewproperty, which will cause the view to be loaded.