iphoneiosxcodeuinavigationcontrolleruitabbarcontroller

View containing navigation bar and tab bar is shifted some 4mm downwards


In my app from a login screen I am navigating to a class say classA, like this:

classA *objUserHome = [[classA alloc]init];
        [self presentModalViewController:objUserHome animated:YES];
        [objUserHome release];

And ClassA is having a navigating bar and a tabbar (5 tabs in it), I have created my tab bar programmatically like this:

- (void)viewDidLoad
{
    [super viewDidLoad];
    //Create tab bar controller and navigation bar controller
    
    tabBarController = [[UITabBarController alloc] init];
    
    NSMutableArray *arrControllers = [[NSMutableArray alloc] initWithCapacity:5];
    
    //Add PunchClock to tab View Controller
    PunchClock* objPunchClock = [[PunchClock alloc] initWithTabBar];
    NavigationController = [[UINavigationController alloc] initWithRootViewController:objPunchClock];
    NavigationController.navigationBar.tintColor = [UIColor brownColor];
    [arrControllers addObject:NavigationController];
    [NavigationController release];
    [objPunchClock release];
    
    //Add Time_Sheet to tab View Controller
    Time_Sheet* objTime_Sheet = [[Time_Sheet alloc] initWithTabBar];
    NavigationController = [[UINavigationController alloc] initWithRootViewController:objTime_Sheet];
    NavigationController.navigationBar.tintColor = [UIColor brownColor];
    [arrControllers addObject:NavigationController];
    [NavigationController release];
    [objTime_Sheet release];
    
    //Add PTO to tab View Controller
    PTO* objPTO = [[PTO alloc] initWithTabBar];
    NavigationController = [[UINavigationController alloc] initWithRootViewController:objPTO];
    NavigationController.navigationBar.tintColor = [UIColor brownColor];
    [arrControllers addObject:NavigationController];
    [NavigationController release];
    [objPTO release];
    
    //Add PunchClock to tab View Controller
    CrewPunch* objCrewPunch = [[CrewPunch alloc] initWithTabBar];
    NavigationController = [[UINavigationController alloc] initWithRootViewController:objCrewPunch];
    NavigationController.navigationBar.tintColor = [UIColor brownColor];
    [arrControllers addObject:NavigationController];
    [NavigationController release];
    [objCrewPunch release];
    
    //Add PunchClock to tab View Controller
    Reports* objReports = [[Reports alloc] initWithTabBar];
    NavigationController = [[UINavigationController alloc] initWithRootViewController:objReports];
    NavigationController.navigationBar.tintColor = [UIColor brownColor];
    [arrControllers addObject:NavigationController];
    [NavigationController release];
    [objReports release];
    
    // Add this view controller array into the tab bar
    
    //self .viewControllers = arrControllers;
     tabBarController .viewControllers = arrControllers;
   
    [arrControllers release];
    [self.view addSubview:[tabBarController view]];
    
   
}

And ClassA is inherited from UIViewController

Now the problem is, after navigating to classA, view of classA is shifted some 4mm downwards per the image below. Why is it so? How can I fix this?

like this


Solution

  • After a long research i finally fixed this issue just by inheriting the class from UINavigationController instead of UIViewControler