【问题标题】:Converting View from Landscape to Portrait?将视图从横向转换为纵向?
【发布时间】:2012-09-21 19:37:55
【问题描述】:
我已经开发了横向模式的应用程序,现在客户要求在横向和纵向模式下构建。
如何将横向视图转换为纵向视图?
现在我将这段代码用于横向视图:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
请帮帮我....
提前谢谢:)
【问题讨论】:
标签:
objective-c
ios
cocoa-touch
uiinterfaceorientation
【解决方案1】:
简单,支持所有方向只需返回YES 到shouldAutorotateToInterfaceOrientation。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
//Or to support all but portrait upside down
return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
【解决方案2】:
了解如何使用自动调整大小的蒙版。它们很简单,但在大多数情况下非常强大。
【解决方案3】:
NSPostWhenIdle 是对的。您只需要返回 yes shouldAutorotateToInterfaceOrientation。这样您就可以支持所有方向。看看通过 XIB 调整属性大小。这也将使您的工作变得轻松。