こんにちは、iOS 6 で autolayout を使用している場合、rootViewController の「rootView」が適切にサイズ変更されていないようです。
私の 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 のビューのサイズは変更されません。xibの「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);
}
誰かが私がここで欠けているものを教えてもらえますか? 私はこの問題で何時間も無駄にしましたが、どこにも行きません^^
どうも