Multiview Applications




CS185c

Chris Pollett

Oct. 5, 2009

Outline

Remembering Multiview App So Far

Modifying MainWindow.xib

SwitchViewController Implementation

#import "SwitchViewController.h"
#import "BlueViewController.h"
#import "YellowViewController.h"

@implementation SwitchViewController

@synthesize blueViewController;
@synthesize yellowViewController;


- (void)viewDidLoad {
        // set up blue controller
	BlueViewController *blueController = [[BlueViewController alloc] 
           initWithNibName:@"BlueView" bundle:nil];
	self.blueViewController = blueController;
        // initial use blue view
	[self.view insertSubview:blueController.view atIndex: 0]; 
             //index 0 behind everything
	[blueController release];
}

- (void) switchViews:(id)sender
{
	// load Yellow nib first time button is pressed
	if(self.yellowViewController == nil)
	{
		YellowViewController *yellowController =
		   [[YellowViewController alloc] 
                   initWithNibName:@"YellowView" bundle:nil];
		self.yellowViewController = yellowController;
		[yellowController release];
	}
        
        //check if not Blue View
	if(self.blueViewController.view.superview == nil)
	{
		[yellowViewController.view removeFromSuperview];
		[self.view insertSubview:blueViewController.view atIndex:0];
	}
	else
	{
		[blueViewController.view removeFromSuperview];
		[self.view insertSubview:yellowViewController.view atIndex:0];
	}
	
}
//... rest of boilerplate code unchanged

- (void)dealloc {
    [blueViewController release];	
    [yellowViewController release];
    [super dealloc];
	
}

@end

Quiz

Which of the following statements is true:

  1. SQLiteOpenHelper is an abstract class with two methods onCreate and onUpgrade that need to be implemented.
  2. Databases on iPhone are stored in /data/data/[PACKAGE_NAME]/database/.
  3. iPhone does not have any array methods which can write to a file.

Implementing Content Views

BlueViewController Implementation

Animating the Transition