开发者

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 [se开发者_运维技巧lf abc] function. how can i solve this?


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
    }
}


@mahesh In shouldAutoRototate Method

      use

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

{ } else { }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜