2010-03-02 6 views
1

Je suis nouveau sur le développement de l'iphone. Dans mon application, j'utilise le nombre de viewControllers, vue Web, barre d'outils, barre d'onglet et ainsi de suite. Ici, je veux réaliser l'orientation (portrait ou paysage ou vice versa) de la vue de l'appareil correspondant dans toutes les vues Web. Je pourrais réaliser l'orientation dans toutes les vues de Web excepté ces affichages de Web viennent sous la vue de Web de contrôleur de barre d'onglets (il peut être un de vue de contrôleur de barre d'onglets ou sous vue d'affichage de contrôleur de barre d'onglets).Problèmes d'orientation avec le contrôleur Tab Tab In WebView

Ici, j'ajouter l'affichage Web en utilisant ci-dessous le code,

contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
    contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |     UIViewAutoresizingFlexibleHeight); 
    self.view = contentView; 
    self.view.autoresizesSubviews = YES; 


    CGRect webFrame = [[UIScreen mainScreen] applicationFrame]; 
    webFrame.origin.y -= 20.0; 

    webView1 = [[UIWebView alloc] initWithFrame:webFrame]; 

    [contentView addSubview:webView1]; 

et en utilisant ci-dessous les méthodes pour atteindre l'orientation,

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
{ 

    return YES; 
} 


- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
    { 
      if(fromInterfaceOrientation == UIInterfaceOrientationPortrait){ 
      [webView1 stringByEvaluatingJavaScriptFromString:@"rotate(0)"]; 

    } 

autre {

[webView1 stringByEvaluatingJavaScriptFromString:@"rotate(1)"]; 
} 

}

s'il vous plaît tout donner un soln!

Répondre

2

Ok permet d'essayer ceci:

Étape 1: Crate une classe personnalisée pour la classe TabBarController comme:

@interface CustomTabBarController : UITabBarController { 

} 

@end 

In CustomTabBarController.m write 

`#import "CustomTabBarController.h" 

@implementation CustomTabBarController 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    // Always returning YES means the view will rotate to accomodate any orientation. 

    return YES; 

} 

@end 

Étape 2: Sur appDelegate écrire ceci:

changement UITabBarController "CustomTabBarController" et modifiez la référence de classe dans le Générateur d'interface à CustomTabBarController