2012-09-27 117 views
1

嗨,当在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

+0

我面临同样的问题。我无法找到解决方案。你找到了吗?调用po [[UIWindow keyWindow] _autolayoutTrace]之后调用 – Amnysia

回答

1

看来,很多事情可以去错的自动版式功能的iOS 6含糊的限制,未能禁用translatesAutoresizingMaskIntoConstraints在你的视图控制器可能会导致很多冲突因此,请通过调用lldb中的autolayoutTrace方法来确保约束中不存在歧义:po [[UIWindow keyWindow] _autolayoutTrace] 如果存在歧义,则必须解决它们。

+0

,它仅打印出整个UI层次结构,如何知道哪一个导致歧义 –

相关问题