从子视图-iOS更改界面方向

从子视图-iOS更改界面方向,ios,subview,uiinterfaceorientation,Ios,Subview,Uiinterfaceorientation,我有一个iPhone应用程序,它总是人像的。但是我需要旋转一个视图来显示一个表。 该按钮位于子视图中。我有以下代码: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } 但由于此视图是从子视图调用的,因此忽略了

我有一个iPhone应用程序,它总是人像的。但是我需要旋转一个视图来显示一个表。 该按钮位于子视图中。我有以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
但由于此视图是从子视图调用的,因此忽略了接口方向

有没有办法改变界面方向


谢谢

您尝试过以下方法吗


[UIApplication sharedApplication].StatusBaroOrientation=UIInterfaceOrientation和ScapeRight

需要在要旋转的视图上设置变换,然后将其设置回标识变换

这将在纵向和横向之间切换

 UIView* viewToTransform = self.newview;
    if (CGAffineTransformIsIdentity(viewToTransform.transform)) {
        CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI/2);
        viewToTransform.transform = transform;

    }else{
        viewToTransform.transform = CGAffineTransformIdentity;
    }

更好的做法是,将现有转换保存在属性中,以便以后可以重置它(这将处理原始转换不是标识转换的情况)。

我这样做了,但没有结果,可能我需要一些导入??谢谢您是要旋转屏幕上的所有内容还是只旋转一个子视图?