使用xib的状态栏问题

时间:2014-06-23 05:08:05

标签: ios iphone objective-c

我使用ViewCrontroller创建了两个xibUIViews的方向设置为LandscapeLeft

然后将此代码添加到

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

enter image description here

以下是我理想的结果:

  1. 我想要ios 7中状态栏下的窗口,

  2. 第一个视图,结果是我想要的,然而,当它跳转到第二个视图时,有一个问题!窗口向左移动20px。如何将其融入普通视图?

  3. 3.最大的不可侵犯条件是Autolayout是“TRUE”。

    我的测试代码: https://www.dropbox.com/s/bj9wg4hwar1t8y0/statusbartesting.zip

    任何人都可以帮忙解决这个问题吗?

    enter image description here

    enter image description here

1 个答案:

答案 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)];
}