UIViewController
A UIViewController controls UIViews. It allows you to switch between UIViews, rotate the screen, etc.
You would generally create a UIView in a UIViewController's loadView method.
Examples
// in the loadView method
UIView *myView =
[ [UIView alloc]
initWithFrame:[[UIScreen mainScreen]
applicationFrame] ];
self.view = myView;
[myView release];
// Displaying new views:
MyController *controller =
[[MyController alloc] init];
[self presentModalViewController:controller
animated:YES];
[controller release];
and to dismiss the controller:
[self dismissModalViewControllerAnimated:YES];
or use a UINavigational controller
[self.navigationController
pushViewController:myController
animated:YES];
[[self navigationController]
popViewControllerAnimated:YES];
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
}
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
switch (orientation)
{
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
{
[webView setFrame:CGRectMake(0,0,480,320)];
break;
}
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
{
[webView setFrame:CGRectMake(0,0,320,460)];
break;
}
}
}