Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to keep a view persistent behind all views in Navigation Controller
    primarykey
    data
    text
    <p>and thanks in advance.</p> <p>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</p> <p>This is how it is set up currently: </p> <ul> <li>AppDelegate makes a navigations controller, RootViewController and a Sprite Layer (which subclasses UIView)</li> <li>AppDelegate also holds the background image as its backgroundColor property</li> <li>the navigation controller is initialized with the root view controller, as normal</li> <li>the rootview controller pushes different table views onto the navigation stack</li> </ul> <p>And in code:</p> <pre><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; } </code></pre> <p>`</p> <p>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. </p> <p>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.</p> <p>Any opinions here?</p> <p>Cheers, Rich</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload