如何旋转添加到窗口的子视图?

时间:2013-04-08 13:54:39

标签: ios objective-c cocoa-touch

我有一个UITabBarController子类,我必须遵循以下代码:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
} 

效果很好,当我翻转设备时有一个旋转。我的问题是,在我的应用程序的某些部分,我希望一个图层位于所有内容之上,例如登录屏幕等等。所以我用这个:

LoginView *loginView = [[LoginView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame delegate:self];
[[UIApplication sharedApplication].keyWindow addSubview:loginView]; //<-- Won't rotate

//[self.view addSubview:loginView]; <-- will rotate but will not be on top of everything (tabbar etc')

在这种情况下,登录屏幕不会旋转。我怎样才能拥有一个覆盖所有内容的子视图,并且仍像其他所有视图一样强制旋转?

0 个答案:

没有答案