Mahesh Babu
Mahesh Babu

Reputation: 3433

Rotating landscape mode

what i did is displaying 10 images as grid and 3 images in portroide mode, and what i did is when ever i rotate the simulator to landscape then i have to display 4 images.It is also displayed using the code

if(self.interfaceorientation == UIIntefaceorientationPortrait) {
[self abc];
else {
[self abclandscape];
}

here abc and abclandscape are two functions it works fine but, it works from initial means form starting if i rotate to landscape mode or portrait mode it works fine .while in the middle if i rotate from landscape to portrait it does 't goes to [self abc] function. how can i solve this?

Upvotes: 0

Views: 297

Answers (2)

Paul Peelen
Paul Peelen

Reputation: 10329

What you could do is either use the UIViewController delegates, or use the NSNoticationCenter.
I.E. add in your "viewDidLoad":

        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
                                                     name:UIDeviceOrientationDidChangeNotification object:nil];

And add the function:

- (void)orientationChanged:(NSNotification *)notification
{   
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
    if (UIDeviceOrientationIsLandscape(deviceOrientation))
    {
    // Do one thing
    }
    else 
    {
    // Do something else
    }
}

Upvotes: 1

arunkumar.p
arunkumar.p

Reputation: 1775

@mahesh In shouldAutoRototate Method

      use

     if(self.interfaceorientation == UIIntefaceorientationPortrait||self.interfaceorientation == UIIntefaceorientationPortraitUp..)

{ } else { }

Upvotes: 0

Related Questions