开发者

iPad Landscape only (left or right)

I am building an app and I would like it to be landscape only, even 开发者_高级运维if rotated. After reading around, I have set up aline of code like this:

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

This works, but I would like the interface to rotate but always in landscape mode only, with left or right home button, like many other apps do...

How to get this?


Try this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}


You're very close, just need to support all landscape orientations, most easily done using the UIInterfaceOrientationIsLandscape macro.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}


A useful link to describe how to build a landscape only app in iPhone, but it also works in iPad. http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜