iphone - 从非事件状态返回时,uinavigationbar 向上移动

标签 iphone ios cocoa-touch uinavigationcontroller uinavigationbar

我在 uinavigationbar 上方有一个自定义图像标题。我使用以下代码执行此操作:

self.navController.view.frame = CGRectMake(0.0, 0.0, 320.0, 480.0); 
self.navController.navigationBar.frame = CGRectMake(0.0, 73.0, 320.0, 44.0);

UIView *checkNav = [self.navController.view viewWithTag:9999];
if (checkNav == nil) {
    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"header-logo.jpg"]];
    imgView.tag = 9999;
    [imgView setFrame:CGRectMake(0.0, 23.0, 320.0, 50.0)];
    [self.navController.view addSubview:imgView];
}

这很好用。但是,当该应用程序进入非事件状态(点击主 iphone 主屏幕按钮)然后您返回到该应用程序时,uinavigationbar 会向上移动到屏幕顶部的默认位置并隐藏在我的自定义标题图像后面。

我试过将代码放入 applicationDidBecomeActive,但没有用。任何帮助将不胜感激。

谢谢!

最佳答案

您确实会在 docs 中收到关于此的警告:

With only a few exceptions, you should never modify the navigation bar object directly. It is permissible to modify the barStyle or translucent properties of the navigation bar but you must never change its frame, bounds, or alpha values directly

话虽如此,您应该能够通过在 applicationDidBecomeActive 或 applicationWillEnterForeground 中重复上述代码来获得效果,假设您从那里有一个指向导航 Controller 的指针。您可能会发现隐藏和重新显示导航栏是必需的(有点 hack,但它可以帮助 - 我有一个类似的问题隐藏/显示状态栏和导航栏不去它的正确位置)

关于iphone - 从非事件状态返回时,uinavigationbar 向上移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8670769/

相关文章:

iphone - 模态对话框在 iOS 6 上不占用全屏

ios - CAPS 页面菜单 : willMoveToPage delegate method getting error

ios - 从设置应用程序ios获取启用/禁用推送通知事件?

iphone - float 只打印整数?

iphone - 如何替换 UITableViewCell 中的 imageView?

iphone - 有没有办法将数据从核心数据迁移到在线数据库?

iphone - 在 App Purchase 用户取消 tx 而应用程序在后台 : tx state stays on purchasing

iphone - 带有自定义字体的 UILabel 错误呈现

ios - XCode 没有启用纹理图集生成的选项

ios - 是否可以继承 NSURLSessionDownloadTask 来为服务创建专用 API?