Monday, 3 February 2014

Orientation Code for iOS Apps

Orientation Code for iOS Apps



Code implemented in (void)didrotate & (void)viewwillappear

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if((orientation==UIDeviceOrientationLandscapeLeft)||(orientation==UIDeviceOrientationLandscapeRight))
{
// Code
}
else if((orientation == UIDeviceOrientationPortrait) || (orientation == UIDeviceOrientationPortraitUpsideDown) || (orientation == 0))
    {
// Code
}
}


-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    [super viewWillAppear:animated];

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if((orientation==UIDeviceOrientationLandscapeLeft)||(orientation==UIDeviceOrientationLandscapeRight))
{
// Code
}
else if((orientation == UIDeviceOrientationPortrait) || (orientation == UIDeviceOrientationPortraitUpsideDown) || (orientation == 0))
    {
// Code
}
}

No comments: