Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Kieron,</p> <p>Why not have one "slide" view controller and a different image only? Use some sort of data structure to keep information about the buttons, images, and pathways for each slide, and then just keep re-using the same view controller for each slide?</p> <p>The view controller can then dynamically load each image as it transitions between the currently visible view and the next instantiation of itself... It should be possible using only 1 view controller.</p> <p>If you're comfortable with using Interface Builder, keep using the XIB files to lay everything out. However, instead of setting each "File's Owner" to a different view controller, set them all to the same one. Then, inside your <code>IBAction</code> methods (when the user pressed a button), use some logic to say "I am on this view right now, and the user pressed this button, so which one should I go to next?"</p> <p>Then, call a method like <code>loadNewSlide:</code> that might look like this:</p> <pre><code>- (void) loadNewSlide:(NSInteger)slideNumber { // Make a string with the new XIB name NSString* xibName = [NSString stringWithFormat:@"slide-%d",slideNumber]; // Create the next slide view controller (it doesn't matter if you create a slide view // controller from within another slide view controller, remember, they are all just // objects) SlideViewController *newSlideViewController = [[SlideViewController alloc] initWithNibName:xibName bundle:nil]; // Change the view UIWindow *theWindow = [self.view superview]; [self.view removeFromSuperview]; [theWindow addSubview:newSlideViewController.view]; // Release, the view stack now should be retaining the view controller instead [newSlideViewController release]; } </code></pre> <p>This will work MUCH better than running "modally" with 75 view controllers (as you had previously suggested) because this will only keep 1 slide in memory at a time - whatever you are currently looking at - and then will load the next slide just in time to move to it.</p>
 

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