NextStep
NextStep

Reputation: 429

How to Move Object when device orientation get changed?

I am developing an app, in which i have X object and when device orientation get changed, the object should get changed in same direction.

for example, I have an X Object.

Y
|
|
|
|
|
|___________X 

Want to move X object in same direction as device Orientation get changed ?

I am not getting how to do it ?

Please suggest me , How could i do it?

Thanks.

Upvotes: 0

Views: 75

Answers (1)

Calin Chitu
Calin Chitu

Reputation: 1099

You can use viewDidLayouSubviews, see a sample:

-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
    {
     ....
    }
    else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
    {
     .....
    }
    else ...
}

Upvotes: 1

Related Questions