Por favor, ayúdame. Tengo métodos:orientación actual del dispositivo iphone en ViewDidLoad
-(void) getCurrentOrientation{
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if(orientation == UIInterfaceOrientationPortrait){
NSLog(@"portrait");
} else if(orientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"LandscapeRight");
} else if(orientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"LandscapeLeft");
}
}
pero cuando llamo a esto getCurrentOrientation tiro viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
[self getCurrentOrientation];
}
NSLog está vacía. ¿Qué pasa? también trato
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait)) {
NSLog(@"portrait");
} else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
{
NSLog(@"LandscapeRight");
}
}
sino que también varint vacía.
¡Tengo que saber en qué ORIENTACIÓN el usuario lanza la APLICACIÓN!
Por favor, dame algún consejo.
Gracias. Pero cuando corro en simulador en modo LANDSCAPE, NSlog da salida a PORTRAIT. Por lo tanto, no estoy seguro de que vaya a corregir el trabajo en el dispositivo real –
Revise la respuesta actualizada –
Selecciono en Proyecto - Objetivo - Resumen - Orientación del dispositivo compatible solo PAISAJE. Pero cuando ejecuto la aplicación en el sumulador con su función Nslog, retrato de salida. ¿Y por qué no debería depender? Solo necesito saber en qué orientación USER ejecuta la aplicación. –