This has got to be the most bizarre thing I’ve ever seen. So I’ll go and set up a event handler from an object created with IB, then I’ll write some code like:
[connectedObjectViaIB setBackgroundColor:[UIColor blackColor]];
also tried :
connectedObjectViaIB.backgroundColor = [UIColor blackColor];
And even though the event handler gets called, and does go through this code (tested with breakpoints) the background Doesn’t get set. The Outlet doesn’t seem to be connected even though it appears it is. This is happening with a couple of other IB objects and other property setters. Anyone experienced this?
From the sound of it (code is running, but no changes are seen) you are calling this code too early.
In a view controller, none of the outlets are connected until after the base
viewDidLoadhas been run. Before then, the value of all the outlet variables will be nil.A common case where code like yours does not work is when calling from a
prepareForSeguemethod – the destination view controller’s view has not yet been loaded, so the outlets are nil.Another is just after initialising a new controller – again, the view has not loaded yet.