在我的应用程序中,我想根据 iPhone 的主页按钮方向设置 UIView 方向。我使用以下方式完成了它:
/* I handled view orientation in shouldAutorotate method*/
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
viewForBarButtons.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
viewForBarButtons.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
else if (interfaceOrientation == UIInterfaceOrientationPortrait)
viewForBarButtons.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
viewForBarButtons.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
其中 viewForBarButtons 是 viewController 中的 UIView。
但是如果我设置 return Yes 而不是 return (interfaceOrientation == UIInterfaceOrientationPortrait); 然后它不起作用。
如何解决这个问题。如果有人知道,请帮助我。LifeCards 应用程序中实现了类似的功能。提前致谢。