开发者

iPhone app alters view on willChangeStatusBarFrame and suspend

开发者 https://www.devze.com 2023-01-24 17:33 出处:网络
In my application, I have a UINavigationController with a UINavigationBar that I created programmatically. The UINavigationBar has custom positioning within the view, but whenever will/didChangeStatus

In my application, I have a UINavigationController with a UINavigationBar that I created programmatically. The UINavigationBar has custom positioning within the view, but whenever will/didChangeStatusBarFrame is called (when you enable the in-call status bar), or the app suspends and resumes, the navBar automagically moves back to the top of the screen.

I was able to override this behavior somewhat by keeping my navBar in place at the bottom, but now it creates a SECOND navBar which it moves to the top.

Why is this happening, and how do I开发者_开发技巧 prevent it from happening? This is a new issue with iOS 4 - the app ran fine in both 2.x and 3.x.

Also, before a discussion about Human Interface Guidelines is started, please note that I'm aware Apple doesn't want UINavigationBars at the bottom. However, this is a custom app that will be used by me and me alone, and I require that the bar be at the bottom. Additionally, this issue is driving me nuts and I want to know the answer no matter where my navBar lies...


Whelp, this is a bit of a hack, but it works. To keep the navBar at the bottom when the in-call status is displayed:

- (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame {
    [navigationController setNavigationBarHidden:YES];
}

- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame {
    [navigationController setNavigationBarHidden:NO];
    CGSize s2 = navBar.bounds.size;
    [navBar setFrame:CGRectMake(0, [navigationController.view bounds].size.height-s2.height, s2.width, s2.height)];

}

And since multitasking with this app is not only unnecessary but also unwanted, I disabled it by adding the following to the plist:

Application does not run in background

This still doesn't really answer my question about why the navBar was jumping to the top, and it's a hackish fix, but it will have to work for now.

0

精彩评论

暂无评论...
验证码 换一张
取 消