2012-07-09 27 views
1

從登錄屏幕要前往一類我的應用程序說CLASSA,這樣查看包含導航欄和標籤欄移到一些4毫米向下

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

和ClassA的是有一個導航欄和的TabBar (在這5個選項卡),我創建了我的標籤欄編程這樣

- (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]]; 


} 

而且ClassA is inherited from UIViewController

現在的問題是,導航到CLASSA,鑑於CL的後assA向下移動約4mm like this爲何如此?我該如何解決這個問題,請幫助我,提前thanx

+0

你使用界面生成器:

這可以通過使用可以預防嗎? (對於視圖,而不是特定的標籤欄),因爲視圖可能設置得太小? – nbsp 2012-07-09 04:58:21

+0

@nbsp不,我沒有使用XIB,編程方式我創建了視圖 – Ravi 2012-07-09 05:04:23

回答

0

長期研究後,我最後只由UINavigationController而不是UIViewControler

0

您可能已經在Interface Builder或XIB文件中選擇了一些頂欄,並另外設置了導航欄。不要在XIB文件中選擇任何頂部欄。

+0

不,我沒有在XIB – Ravi 2012-07-09 05:33:59

0

嘗試如下

[self.navigationController.view addSubview:[tabBarController view]]; 
+0

中做過它的給出一個空白屏幕,查看內容是隱形的 – Ravi 2012-07-09 05:33:40

1

繼承類使用時可能會遇到2個或多個視圖之間的故事板和Modal Transition修復了這個問題類似於上面的錯誤。

如果使用Modal TransitionViewControllerAViewControllerZ,然後從ViewControllerZ嘗試Modal TransitionViewControllerA有時ViewControllerA的觀點被小幅上推下車窗。

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; 

ViewControllerZ從事件回去ViewControllerAViewControllerZ

+0

你的開頭段落很混亂 – thecoshman 2012-10-10 12:54:11