Define previousOrientation first, as below in your class.h file
UIDeviceOrientation previousOrientation;
- (id)init {
    if ((self=[super init])) {
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(orientationChanged: )
                                                    name:@"UIDeviceOrientationDidChangeNotification" object:nil];
    }
}
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (previousOrientation == UIDeviceOrientationPortrait)
    {NSLog(@"PORTRAIT");
}
    else if (previousOrientation == UIDeviceOrientationLandscapeLeft)
    {NSLog(@"LANDSCAPE LEFT");
}
    else if (previousOrientation == UIDeviceOrientationLandscapeRight)
    {NSLog(@"LANDSCAPE RIGHT");
}
else
{
NSLog(@"PORTRAIT DOWN");
}
}
 
No comments:
Post a Comment