0

我想为 iPad 中的状态栏创建类似于 UIView 向下滑动的东西。但它仅适用于纵向模式。当我将 iPad 旋转到横向模式时, UIView 仍然以纵向模式滑动。

4

2 回答 2

1

这是因为您将其添加到窗口

If you add an additional view controller's UIView property to UIWindow (at the same level as your primary view controller) via the following:

[myWindow addSubview:anotherController.view];

this additional view controller will not receive rotation events and will never rotate. Only the first view controller added to UIWindow will rotate.

所以试试这个:

UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) 
    window = [[UIApplication sharedApplication].windows objectAtIndex:0];
[[[window subviews] objectAtIndex:0] addSubview:myView];    
于 2012-11-17T11:03:36.473 回答
-1

You should try:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

Just put it in your viewcontroller.m file.

于 2012-07-24T02:39:45.570 回答