0

Hi i am new to ios development...

I have created on project that supports for only landscape only.For that i used like this settings image

But when i am going to print view sizes

  NSLog(@"%f--%f",self.view.frame.size.width,self.view.frame.size.height);

in log it giving

   768.000000--1024.000000

instead of

 1024.000000--768.000000

And also i added a code

   - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
          {
         BOOL res=((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)||       (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
return res;
        }

I have no idea how to solve this problem.Please help me on this

sudheer
  • 418
  • 6
  • 20
  • SO has loads of answers for this very question. See this for example: http://stackoverflow.com/questions/12650137/how-to-change-the-device-orientation-programmatically-in-ios-6 – Arsalan Habib Oct 25 '13 at 17:43
  • I am using xcode5 and ios7.0.In that it showing error 'No Visible @Interface for [UIDevice] setOrientation:' How to achieve this....? – sudheer Oct 25 '13 at 17:50

1 Answers1

1

Sometime even setting like this fail check solution

In the properties file for your app (YOURAPPNAME-Info.plist), There is an array called "Supported interface orientations". Remove the orientations you don't want from the array, and your app will be locked into the remaining orientation.

In iOS 6 setOrientation is depreciated, you should replace it with:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

and return true only for landscapes in orientation methods

Aditya Deshmane
  • 4,676
  • 2
  • 29
  • 35