views:

74

answers:

1

Hi there.

Basically I've got the same background image throughout my entire iphone application.

I don't use XIBs (nasty things :p).

So I was wondering if there was any way to add a "default" background image to all of my UIViewControllers?

I tried subclassing UIViewController and created the class UIViewControllerWithDefaultBackground, but changing over all my uiviewcontrollers to subclass UIViewControllerWithDefaultBackground just crashes my app. Plus half of my views are UITableViewControllers... but I'd be happy just having to change 2 classes... :p

Is there any way of doing this? I just don't want to have to copy and paste the same 3 or 4 lines of code into every single class I'm initiating. Plus, if I want to edit it at any point (take out the navigation bar and extend the view lets say) then I would have to change all my different classes.

Is there no easy way to do this programatically?

Thanks Tom

A: 

If you add a UIImageView to your UIWindow in your app delegate (make sure it's below the root view), then make sure all your VC's are opaque, that should solve your problem.

This would be easier to do in IB, especially if you have a MainWindow .xib already created (albeit blank)--you just drag and drop the image into the UIWindow.

MishieMoo
thats a good idea, and seeing as i don't have any other answers I shall try it. I also found out that you can add a background image to the navigation controller. :) Which is easier.
Thomas Clayson