0

UINavigationBar Appears Under UIStatusBar in iOS 6(It runs properly in iOS 7), I am using storyboard with Xocde 5,

: Here is my code snippet,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [UIApplication sharedApplication].statusBarHidden = NO;

    if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7) //iOS 6
    {
        [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"TabImg.png"]];
        [[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:.7 green:.2 blue:.1 alpha:1.0]];
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
    }

    return YES;
}

Code on HomePage,

- (void)viewDidLoad
{
    [super viewDidLoad];

        CRViewController *Obj=[[CRViewController alloc] init];
        [self.tabBarController presentViewController:Obj animated:YES completion:nil];

}

When i run my app after didFinishLaunchingWithOptions method viewDidLoad gets fired and this calls CRViewController class.

Code on CRViewController,

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.navigationController setNavigationBarHidden:YES];
    self.tabBarController.tabBar.hidden = YES;
    [UIApplication sharedApplication].statusBarHidden = YES;

     ...
     ...
     ...

}



- (IBAction)SkipClick:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)viewDidDisappear:(BOOL)animated{
    [self.navigationController setNavigationBarHidden:NO];
    self.tabBarController.tabBar.hidden = NO;
    [UIApplication sharedApplication].statusBarHidden = NO;
}

Where i am doing mistake ??

Thanks in advance.

Krunal
  • 6,440
  • 21
  • 91
  • 155
  • Hi, i am facing same issue in my app,set time delay after present your view controller – NANNAV Oct 11 '13 at 09:29
  • try this - (void)viewDidLoad { [super viewDidLoad]; [self performSelector:@selector(presentListView) withObject:self afterDelay:0.5]; } -(void)presentListView { CRViewController *Obj=[[CRViewController alloc] init]; [self.tabBarController presentViewController:Obj animated:YES completion:nil]; } – NANNAV Oct 11 '13 at 10:09

1 Answers1

0
Navigation is showing in ios 7 than you have check this it will work


NSString *version = [[UIDevice currentDevice] systemVersion];
int ver = [version intValue];
if (ver > 7)
{
}
else
{
    self.edgesForExtendedLayout = UIRectEdgeNone;

}

self.tabBarController.tabBar.hidden = YES; is not working in ios 7 it shows the black screen. Than you can hide it

-(void)hideTabBar

{

UITabBar *tabBar = self.tabBarController.tabBar;

UIView *parent = tabBar.superview; // UILayoutContainerView

UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView

UIView *window = parent.superview;

[UIView animateWithDuration:0.5

animations:^ {

CGRect tabFrame = tabBar.frame;

tabFrame.origin.y = CGRectGetMaxY(window.bounds);

tabBar.frame = tabFrame; content.frame = window.bounds;

}];

}