嗨,当在iOS 6上使用自动布局时,我的rootViewController的“rootView”似乎没有正确调整大小,如果有的话。RootViewController的视图不是用自动布局调整大小
我的RootViewController的是从笔尖加载,我将它添加到视图层次结构是这样的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
RootVC *rootVC = [[RootVC alloc] initWithNibName:@"RootVC" bundle:nil];
self.window.rootViewController = rootVC;
return YES;
}
但是,当我旋转模拟器rootVC犯规调整大小的视图。既然你不能设置任何约束,在厦门国际银行的“rootview”,我也试过,但没有任何效果:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
RootVC *rootVC = [[RootVC alloc] initWithNibName:@"RootVC" bundle:nil];
self.window.rootViewController = rootVC;
NSArray *vConst = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:@{@"view" : rootVC.view}];
NSArray *hConst = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|" options:0 metrics:nil views:@{@"view" : rootVC.view}];
[self.window addConstraints:vConst];
[self.window addConstraints:hConst];
return YES;
}
当我登录时的rootvc的视图的帧大小,它总是肖像格式(W:768,H:1024)
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
NSLog(@"%f, %f", self.view.frame.size.width, self.view.frame.size.height);
}
可能有人请告诉我什么,我在这里失踪?我已经浪费了这个问题小时,毫无进展^^
THX
我面临同样的问题。我无法找到解决方案。你找到了吗?调用po [[UIWindow keyWindow] _autolayoutTrace]之后调用 – Amnysia