现在的位置: 首页 > 综合 > 正文

关于 ios4. 系统的statusbar 隐藏后顶部出现横条问题

2017年12月09日 ⁄ 综合 ⁄ 共 1020字 ⁄ 字号 评论关闭

在进入全屏模式的时候,顶部的statusbar 进行了隐藏,但是顶部任然有一个20像素的横条;

测试过程中仅仅在ios 4中会出现这种问题,在网上搜索到的很多答案都是采用, xx-Info.plist 里面加入

然后在需要加载statusbar的地方加入

[[UIApplication sharedApplication] setStatusBarHidden:NO];

来解决问题,但是这种方法无法从根本解决这个问题。

经过分析,在viewController的底部采用的是一个 UINavigationViewContrller,而这里采用的是直接从控件列表拖拽到IB设计的地方;然后与mainVIewController进行关联。

而在采用纯代码去实现这一个过程后重新测试时,上面的蓝色横条消失了,如此经过测试可以发现这应该是系统的bug,所以建议还是采用纯代码的方式实现这一个过程,不要直接拖拽UINavigatiopnViewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    UINavigationController *navigation = [[[UINavigationController alloc]initWithRootViewController:self.viewController] autorelease];

    [navigation setNavigationBarHidden:YES animated:NO];
    self.window.rootViewController = navigation;
    [self.window makeKeyAndVisible];
    return YES;
}

抱歉!评论已关闭.