Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: how to build a landscape only iphone program

Tags:

xcode

iphone

in Xcode, I tried to design a landscape only user interface.

I both set UIViewController and UIView controls to landscape model. but when I placed the controls, like buttons, images on the UIView, when programe running, only the controls which are placed on top-left area response. Seems the programe is still running in portrait mode.

like image 934
Xcobe Avatar asked May 22 '26 08:05

Xcobe


1 Answers

In project plist setup Initial interface orientation field in Landscape (left home button). Also setup Supported interface orientations field.

And override method -(BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation in your ViewController:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
like image 72
Alex Nazarov Avatar answered May 24 '26 22:05

Alex Nazarov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!