Can't set background colour for UIView from ViewController
Posted
by Curyous
on Stack Overflow
See other posts from Stack Overflow
or by Curyous
Published on 2010-05-17T09:03:38Z
Indexed on
2010/05/17
9:40 UTC
Read the original article
Hit count: 346
I have the following code in the view controller:
- (void)viewDidLoad {
[super viewDidLoad];
ThemeManager *themer = [ThemeManager sharedInstance];
UIView *theView = self.view;
UIColor *forBackground = [themer backgroundColour];
[theView setBackgroundColor:forBackground];
}
but when execution gets to the setBackgroundColor line, I get the following error:
*** -[NSCFNumber CGColor]: unrecognized selector sent to instance 0x1237c40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFNumber CGColor]: unrecognized selector sent to instance 0x1237c40'
There's got to be something simple that I'm doing wrong, how do I set the background colour?
Do I have to subclass the view and do it in there? I'd prefer not to have the extra class, even though that is better separation of the whole model/view/controller thing.
Update: value returned by [themer backgroundColour]
is constructed using colorWithPatternImage:
, could this make a difference?
© Stack Overflow or respective owner