I've made an iPad application,
It works fine when I load my application in portrait mode for first time, but when I load my application in landscape mode for the first time, it takes the coordinates of portrait mode only, because inside my didLoad
method I give coordinates of portrait mode only.
Now need to give coordinates of landscape mode inside my didLoad
method.
I tried this, inside my didLoad method
if (interfaceOrientation == UIInterfacePortraitmode ||
interfaceOrientation == UIInterfaceUpsideDown)
{
// do this....
}
else
{
// do this....
}
but I am unable to write the condition for the if/else inside my didLoad
method.
What should I do?
-(void) viewWillAppear: (BOOL) animated {
[super viewWillAppear: animated];
[self adjustViewtForNewOrientation: self.interfaceOrientation];
}
-(void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation duration: (NSTimeInterval) duration {
[self adjustViewtForNewOrientation: interfaceOrientation];
}
- (void) adjustViewtForNewOrientation: (UIInterfaceOrientation) orientation {
if (UIInterfaceOrientationIsLandscape(orientation)) {
// Do some stuff
} else {
// Do some other stuff
}
also call adjustViewtForNewOrientation
in your ViewDidLaod() method,