在我的应用程序中,我想根据iPhone的home按钮方向设置UIView方向。我使用以下方法完成:修复iphone中的uiview位置sdk
/* 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。
但是,如果我设置返回是而不是返回(interfaceOrientation == UIInterfaceOrientationPortrait);那么它不起作用。
如何解决此问题。如果有人知道它,那么请帮助我。 类似的功能在LifeCards应用中实现。 在此先感谢。
替代自行但是,如果我改变观点的起源,然后它的子视图得到打扰。 – Girish 2012-04-25 10:57:09
可能有一种可能性。创建一个大小为父视图(只有填充需要比viewForBarButtons更多)并添加viewForBarButtons到它。为viewForBarButton设置所需的自动调整大小掩码。添加superview到contatiner并调整到整个视图(不要忘记设置灵活的高度和宽度)。这应该工作。 – 2012-04-25 11:24:58
我曾评论说,这将是“在改变方向期间在其他方面的先前位置”。它会根据基于它所添加的超级观点的立场来审议案件。对先前的错误抱歉。 – 2012-04-25 11:26:27