Question

I am working on an application that consists of a TabBar controller. Within on of its tab, I have a subclass of UITableViewController, within this list I have a Core-plot graph in the first cell and some other data in the 4 following cells. When I return YES in the shouldAutorotateToInterfaceOrientation method, I would expect the autoresizing of the list view to happen, but... nothing. When I add some log in the willRotateToInterfaceOrientation method, they are not displayed. Is there something I missed ? Thanks a lot, Luc

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
NSLog(@"Orientation");
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation  duration:duration];

NSLog(@"Rotating");

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
    NSLog(@"view land:%@", self.view);
}

if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
    NSLog(@"view portrait:%@", self.view);
} 
}
Was it helpful?

Solution

Yes, it won't work unless you subclass UITabBarController and override its shouldAutorotateToInterfaceOrientation: method correctly.

See my question here and related answers.

OTHER TIPS

add this method in category 
@implementation UITabBarController(UITabBarControllerCategory)

-(BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)toInterfaceOrientation
{
  AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];

  if ([AppDelegate isLandScapeOnly]){
    return NO;
 }
return YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top