我使用ViewCrontroller
创建了两个xib
,UIViews
的方向设置为LandscapeLeft
。
然后将此代码添加到
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
以下是我理想的结果:
我想要ios 7
中状态栏下的窗口,
第一个视图,结果是我想要的,然而,当它跳转到第二个视图时,有一个问题!窗口向左移动20px。如何将其融入普通视图?
3.最大的不可侵犯条件是Autolayout
是“TRUE
”。
我的测试代码: https://www.dropbox.com/s/bj9wg4hwar1t8y0/statusbartesting.zip
任何人都可以帮忙解决这个问题吗?
答案 0 :(得分:0)
您无需在AppDelegate中更改窗口框架。
我会告诉你代码,请关注它
Appdelegate.m
- (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];
self.mxfirstciewcontroller = [[firstViewController alloc] initWithNibName:@"firstViewController" bundle:nil];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:self.mxfirstciewcontroller];
[(UINavigationController *)self.window.rootViewController setNavigationBarHidden:YES];
return YES;
}
在firstViewController.m
中- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.view setFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height)];
}
在secondViewController.m
中- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self.view setFrame:CGRectMake(20, 0, self.view.frame.size.width, self.view.frame.size.height)];
}