Graphics Programs Reference
In-Depth Information
• Carefully set the autoresize mask on each subview so that it acts reasonably when
the superview is resized to fill the rotated window.
When the device rotates, view controllers whose views are currently on the screen will be
sent the message shouldAutorotateToInterfaceOrientation: . This method
returns a BOOL that indicates whether it is okay to autorotate the view controller's view.
For iPhone applications, you typically allow right-side up, landscape left, and landscape
right. On the iPad, you typically allow all orientations, including upside-down. In
HeavyViewController.m , implement this method to return YES for the three typical
iPhone orientations.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)x
{
// Return YES if incoming orientation is Portrait
// or either of the Landscapes, otherwise, return NO
return (x == UIInterfaceOrientationPortrait)
|| UIInterfaceOrientationIsLandscape(x);
}
Now let's find something to rotate. Drag any image (smaller than 1024x1024) from Finder
into the project navigator. (Alternatively, you can use the file joeeye.jpg in the solu-
tions at http://www.bignerdranch.com/solutions/iOSProgram-
ming3ed.zip . )
Open HeavyViewController.xib . Drop a slider, an image view, and two buttons
on the view ( Figure 8.4 ) .
Figure 8.4 HeavyViewController XIB layout
 
Search WWH ::




Custom Search