UIViewAutoresizingNone:旋转后调整大小

| 我有一个简单的IPAD结构,带有一个AppDelegate,其中包含来自viewController的视图:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    ClockVC *clockVC = [[ClockVC alloc]init];
    clockVC.view.frame = CGRectMake(100, 100, clockVC.view.bounds.size.width, clockVC.view.bounds.size.height);

    [self.window addSubview:clockVC.view];
    [self.window makeKeyAndVisible];

    return YES;
}
clockVC具有由此代码定义的viewDidLoad:
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.autoresizingMask = UIViewAutoresizingNone;
    self.view.autoresizesSubviews = UIViewAutoresizingNone;
}
clockVC的边界由IB定义,并在application:didFinishLaunching ...中覆盖 宽度和高度分别为200和150。 ClockVC实现了一步自动旋转的方法: /
/ Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{  
     [UIView animateWithDuration:0.5 
                     animations:^{self.view.alpha = 0;}
     ];
}

-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{ 
    [UIView animateWithDuration:1 
                     animations:^{self.view.alpha = 1;}
     ];
}
第一次加载时,将正确查看页面,并且ClockVC视图处于适当位置。 当我旋转clockVC视图(将autoResizeMask设置为UIViewAutoresizingNon)调整大小以占据整个屏幕时。 为什么??我想保留初始大小。 这是我的问题的屏幕截图。 轮换之前: 旋转后:     
已邀请:
不要为此使用根视图,而是将一个子视图添加到视图控制器的视图中。
UIViewControllers
通常用于填充容器的整个空间(在这种情况下为窗口)。 例如,如果您要在
UINavigationController
上添加
UIViewController
,导航控制器将根据导航控制器的布局(无论导航栏是否可见等)来接管缩放视图控制器视图的职责。我不确定UIWindow的行为如何(我认为这没有非常清楚的记录),但是在SDK的很多地方,视图控制器的父级负责其子级的位置和大小(
UIPopoverController
UITabBarController
等)。     

要回复问题请先登录注册