I'm trying to figure out how to set a background image programmatically. I've created a Utility application in xcode, so it has a main view and a flipside view, plus a root view controller. The main view consists of the view class (MainView) and the view controller (MainViewController). The view itself is created in Interface Builder.
Now, I've written a fairly simple method on MainView.m :
However, I can't figure out how to call this. The initWithFrame method on MainView.m is never called (I guess because the view is created in Interface Builder). I've tried adding this line to the MainViewController's initWithNibName function:
but that just results in a crash, saying "objc[34787]: FREED(id): message superview sent to freed object=0x453910".
How can I call custom methods on MainView.m from the view controller object?
I'm guessing maybe I need to create an instance of MainView, but isn't that what self.view is supposed to be?
Thanks,
-j.
Now, I've written a fairly simple method on MainView.m :
Code:
- (void)setBackgroundImage {
UIImageView *customBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]];
background = customBackground;
[customBackground release];
[self addSubview:background];
NSLog(@"Added background subview %@", background);
[self sendSubviewToBack:background];
}
However, I can't figure out how to call this. The initWithFrame method on MainView.m is never called (I guess because the view is created in Interface Builder). I've tried adding this line to the MainViewController's initWithNibName function:
Code:
[self.view setBackgroundImage];
but that just results in a crash, saying "objc[34787]: FREED(id): message superview sent to freed object=0x453910".
How can I call custom methods on MainView.m from the view controller object?
I'm guessing maybe I need to create an instance of MainView, but isn't that what self.view is supposed to be?
Thanks,
-j.