开发者

iphone cannot rotate views in TabBar controller

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);
} 
}


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

See my question here and related answers.


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜