0

I am making iPad Application

and I set the frame of everything in portrait only

but I want the landscape the orientation too

in appTarget I select all the supported interface orientation.

in portrait mode it's working good but when I move it in landscape mode

then my view and my all controls mess out and look very bad

would you please tell me how can I manage all the orientation

and please do tell me in a bit easy detail

Cœur
  • 37,241
  • 25
  • 195
  • 267
zeeshan shaikh
  • 819
  • 3
  • 18
  • 33

2 Answers2

1

Add this to your AppDelegate.m file in order to support both orientations.

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
     return (UIInterfaceOrientationMaskAll);
}
Nikos M.
  • 13,685
  • 4
  • 47
  • 61
1

try this ..... let say you have a button in bottom corner of your ipad . then how to put this at same location in both landscape and portrait mode ...

-(NSUInteger)supportedInterfaceOrientations
{
    if ([[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortrait||[[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortraitUpsideDown) {
        pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
    }
    else
    {
       pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70); 
    }
    return (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskPortraitUpsideDown);
}
-(BOOL)shouldAutorotate
{
    return YES;
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{

    if ([[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortrait||[[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortraitUpsideDown) {
        pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
    }
    else
    {
        pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
    }

    return YES;
}

see you have to override these methods to adjust your gui in both modes , and you have to adjust frame of your GUI elements in these methods . . .

Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70