Specifying the Device Orientation
In the iPhone, I want to display this only in Portrait orientation. Add the code in bold in Listing 20-3 to shouldrotateToInterfaceOrientation:
in DestinationController.m
.
Listing 20-3: Setting the Orientation
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone) {
return (interfaceOrientation ==
UIInterfaceOrientationPortrait);
}
else
return YES;
}
The iPad, as usual, will support any orientation.
Get iPad Application Development For Dummies, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.