在我的应用程序中,从登录界面我导航到一个班级说classA,就像这样
classA *objUserHome = [[classA alloc]init];
[self presentModalViewController:objUserHome animated:YES];
[objUserHome release];
和ClassA有一个导航栏和一个标签栏(其中有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之后,classA的视图向下移动了大约4mm 为什么呢?我怎么能解决这个问题,请提前帮助我,而不是提前
答案 0 :(得分:1)
在2个或更多视图之间使用故事板和Modal Transition
时,您可能会遇到与上述类似的错误。
如果您使用Modal Transition
中的ViewControllerA
到ViewControllerZ
,然后尝试Modal Transition
从ViewControllerZ
返回ViewControllerA
,有时会看到ViewControllerA
{1}}稍微被推下窗口。
使用以下方法可以防止这种情况:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
在ViewControllerZ
上ViewControllerA
从ViewControllerZ
上的活动返回{{1}}
答案 1 :(得分:0)
您可能在Interface Builder或XIB文件中选择了一些顶部栏,并另外设置了导航栏。不要选择XIB文件中的任何顶部栏。
答案 2 :(得分:0)
尝试以下
[self.navigationController.view addSubview:[tabBarController view]];
答案 3 :(得分:0)
经过长时间的研究后,我终于通过继承UINavigationController
而非UIViewControler