2010-04-08 4 views
0

J'ai une application TabBar que je voudrais être en mode paysage et portrait. Le problème est quand je vais à l'onglet 2 faire une sélection de ma table puis sélectionnez l'onglet 1 et faites pivoter l'appareil, puis sélectionnez à nouveau l'onglet 2 le contenu ne sait pas que l'appareil a pivoté et n'affichera pas correctement mon contenu personnalisé. J'essaie d'écrire une méthode qui indique à la vue dans quelle orientation il est actuellement. IN viewDidLoad Je suppose qu'il est en portrait mais dans shouldAutoRotate je l'ai cherché dans la méthode privée pour l'alignement correct du contenu. S'il vous plaît Aidez !! Voici mon code:Problème avec l'affichage Paysage et Portrait dans une application TabBar

#import "DetailViewController.h" 
#import "ScheduleTableViewController.h" 
#import "BrightcoveDemoAppDelegate.h" 
#import "Constants.h" 

@implementation DetailViewController 


@synthesize CurrentLevel, CurrentTitle, tableDataSource,logoName,showDescription,showDescriptionInfo,showTime, showTimeInfo, tableBG; 

- (void)layoutSubviews { 

showLogo.frame = CGRectMake(40, 20, 187, 101); 
showDescription.frame = CGRectMake(85, 140, 330, 65); 
showTime.frame = CGRectMake(130, 10, 149, 119); 
tableBG.frame = CGRectMake(0, 0, 480, 320); 

} 

/* 
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { 
     // Custom initialization 
    } 
    return self; 
} 
*/ 

/* 
// Implement loadView to create a view hierarchy programmatically, without using a nib. 
- (void)loadView { 
} 
*/ 


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
self.navigationItem.title = CurrentTitle; 
[showDescription setEditable:NO]; 
//show the description 
showDescription.text = showDescriptionInfo; 
showTime.text = showTimeInfo; 
NSString *Path = [[NSBundle mainBundle] bundlePath]; 
NSString *ImagePath = [Path stringByAppendingPathComponent:logoName]; 
UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:ImagePath]; 
[showLogo setImage:tempImg]; 
[tempImg release]; 
[self masterView]; 

} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return YES; 
} 

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
isLandscape = UIInterfaceOrientationIsLandscape(toInterfaceOrientation); 
if(isLandscape = YES){ 
[self layoutSubviews]; 

} 

} 





- (void)didReceiveMemoryWarning { 
// Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

// Release any cached data, images, etc that aren't in use. 
} 

- (void)viewDidUnload { 
// Release any retained subviews of the main view. 
// e.g. self.myOutlet = nil; 
} 


- (void)dealloc { 
[logoName release]; 
[showLogo release]; 
[showDescription release]; 
[showDescriptionInfo release]; 
    [super dealloc]; 
} 


@end 

Répondre

0

Je crois que vous devez passer la méthode -shouldAutorotateToInterfaceOrientation: à chaque contrôleur de vue. Vous pourriez faire quelque chose comme ceci dans votre UITabBarController:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) 
      interfaceOrientation 
{ 
    for (UIViewController *viewController in [ self viewControllers ]) 
     [ viewController 
      shouldAutorotateToInterfaceOrientation:interfaceOrientation ]; 

    return YES; 
} 
Questions connexes