状态栏上的自定义视图封面隐藏了导航栏

时间:2013-12-18 16:08:15

标签: ios objective-c ios7 statusbar

窗口的rootViewController是一个navigationController(iOS SDK是7.0。)。

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
MyNavigationController *nav = [[MyNavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = nav;

现在我设置了隐藏在MyNavigationController中的navigationBar:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.navigationBarHidden = YES;

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
        self.automaticallyAdjustsScrollViewInsets = YES;
    }
}
return self;

}

然后在ViewController上添加一个btn:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.navigationBarHidden = YES;

        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
        {
            self.edgesForExtendedLayout = UIRectEdgeNone;
            self.extendedLayoutIncludesOpaqueBars = NO;
            self.modalPresentationCapturesStatusBarAppearance = NO;
            self.automaticallyAdjustsScrollViewInsets = YES;
        }
    }
    return self;
}

但是btn在状态栏上。我怎么能解决它?

0 个答案:

没有答案
相关问题