2009-05-05 10 views
0

Wenn eine modale Ansicht über dem Tab-Controller angezeigt wird, ist die Ausrichtung des Tab-Controllers und meine modale Ansicht derzeit im Hochformat, ich muss nur die Ausrichtung meiner modalen Ansichten ändern Querformat-Modus, Ich versuchte Usign UIDevice Orientierung, aber kein Erfolg, es funktioniert nur, wenn .plist UIDeviceOrientationKey hat, und ich möchte nicht ganze meiner Anwendung im Querformat-Modus. zweitens habe ich sogar versucht, UIApplication setStatusBarOrientation zu verwenden, aber meine Ansicht reagiert nicht darauf, d. h. nur mein Gerät (Simulator) wird gedreht, aber die Ansicht bleibt im Hochformat, die affine Transformation auf UIView erstellt eine leere Ansicht, in der meine Ansicht durch XIB erstellt wird.Ändern der modalen UIView-Ausrichtung in Querformatmodus auf dem iPhone

Bitte Hilfe

Dank Rakesh

Antwort

0

Bis heute habe ich die folgende Lösung verwendet:

-(void)setOrientation:(UIInterfaceOrientation)orientation 
{ 
SEL rotation = @selector(_setRotatableViewOrientation:duration:); 
NSMethodSignature * methodSignature = [window methodSignatureForSelector:rotation]; 
if (methodSignature) 
{ 
    NSInvocation * ivc = [NSInvocation invocationWithMethodSignature:methodSignature]; 
    [ivc setTarget:window]; 
    [ivc setSelector:rotation]; 
    // arg0 will be self, 1 will be cmd_ (current method selector) 
    [ivc setArgument:&orientation atIndex:2]; 
    double duration = 0.4; 
    [ivc setArgument:&duration atIndex:3]; 
    [ivc invoke]; 
} 
} 

-(void)normalizeOrientation 
{ 
UIDeviceOrientation dOrientation = [UIDevice currentDevice].orientation; 

int orientation = -1; 

    switch(dOrientation) 
    { 
     case UIDeviceOrientationPortrait: 
      orientation = UIInterfaceOrientationPortrait; 
      break; 
     case UIDeviceOrientationPortraitUpsideDown: 
      orientation = UIInterfaceOrientationPortraitUpsideDown; 
      break; 
     case UIDeviceOrientationLandscapeRight: 
      orientation = UIInterfaceOrientationLandscapeLeft; 
      break; 
     case UIDeviceOrientationLandscapeLeft: 
      orientation = UIInterfaceOrientationLandscapeRight; 
      break; 
    } 

    if (orientation != -1 && orientation != tabBarController.interfaceOrientation) 
     [self setOrientation:orientation]; 
} 

aber die offizielle App Store wird nicht neue Versionen meiner App nehmen, die auf _setRotatableViewOrientation: Dauer: Übergang : toView: ist keine dokumentierte API.

Also achten Sie darauf, es in Ihren kommerziellen Projekten zu verwenden! Apple neue automatisierte API Checker wird Ihre App ablehnen!

1

Ich habe this verwendet und es funktioniert gut mit einigen Feinabstimmungen.