and thanks in advance.
I am looking for advice on how to layout the view controllers in my app, where I still have a persistent background along with a few background animations
This is how it is set up currently:
- AppDelegate makes a navigations controller, RootViewController and a Sprite Layer (which subclasses UIView)
- AppDelegate also holds the background image as its backgroundColor property
- the navigation controller is initialized with the root view controller, as normal
- the rootview controller pushes different table views onto the navigation stack
And in code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIImageView* backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"underthesea.jpg"]] autorelease];
backgroundView.contentMode = UIViewContentModeScaleAspectFill;
backgroundView.frame = [UIScreen mainScreen].bounds;
self.viewController = [[[RootViewController alloc] init] autorelease];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.spriteLayer = [[[SpriteLayer alloc] initWithFrame:self.viewController.view.frame] autorelease];
self.viewController.spriteLayer = self.spriteLayer;
[window addSubview:backgroundView];
[window addSubview:self.spriteLayer];
[window addSubview:self.navigationController.view];
[window makeKeyAndVisible];
return YES;
}
`
All the time, the Sprite Layer is visible in the background, containing different animations. The problem is that now I am trying to implement autorisizing and having difficulties because the views in the sprite layer are not within a UIViewController.
I think one possibility is to make the SpriteLayer subclass UIViewController, but don't put it in the navigation controller; it would just exist behind whatever view the navigation controller is displaying. I don't know if having 2 view controllers at the same time like this will be a source of bugs or just bad design, as I have read on StackOverflow that this is not the intended design of view controllers.
Any opinions here?
Cheers, Rich
P.S. I am having trouble putting an objective C method within a code block. The back tick doesn't seem to work, as the only part of the code that ends up in the code font is that which is indented. Anyone know the correct way to do this? Thanks again.