Ich arbeite an einer iPhone-Anwendung, die auf UITabBarController und UIViewControllern für jede Seite basiert. Die App muss nur im Portrait-Modus laufen zu lassen, so dass jeder View-Controller + AppDelegate geht mit dieser Codezeile:Manuelle Rotationserkennung
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Es gibt einen View-Controller, wo Ich mag würde einen UIImageView um Pop-up, wenn das iPhone ist rotaed zu landschaftsfrei. Das Design des Bildes sieht wie eine Landschaft aus, obwohl die Breite und Höhe 320x460 (also das Hochformat) betragen.
Wie kann/sollte ich diese Art der Drehung manuell erkennen, nur in diesem speziellen Ansichtscontroller, ohne eine automatische Drehung auf der gesamten Ansicht?
Thomas
UPDATE:
Dank!
Ich habe diesen Zuhörer in der viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:)name:UIDeviceOrientationDidChangeNotification object:nil];
die didRotate wie folgt aussieht:
- (void) didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft)
{
//your code here
}
}
Dank! I hinzugefügt, um diesen Zuhörer im viewDidLoad: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (didRotate:) Name: UIDeviceOrientationDidChangeNotification Objekt: nil]; die didRotate sieht wie folgt aus: - (void) didRotate: (NSNotification *) Benachrichtigung {\t \t UIDeviceOrientation Orientierung = [[UIDevice currentDevice] Orientierung]; \t \t if (Orientierung == UIDeviceOrientationLandscapeLeft) \t { \t \t // Ihr Code hier \t} } –
Minor Verbesserung, verwenden Sie die Konstante UIDeviceOrientationDidChangeNotification statt dessen String-Wert (das ist @ "UIDeviceOrientationDidChangeNotification") –
Vergessen Sie nicht, sich als Zuhörer für das Event abzumelden ... – aroth