在我的应用程序中,我从登录屏幕导航到一个类,比如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,如下图所示。为什么会这样呢?我该如何解决此问题?
的数据
4条答案
按热度按时间new9mtju1#
在两个或更多视图之间使用故事板和
Modal Transition
时,您可能会遇到类似于上面的错误。如果您使用
Modal Transition
从ViewControllerA
到ViewControllerZ
,然后尝试从ViewControllerZ
返回到ViewControllerA
的Modal Transition
,有时ViewControllerA
的视图会稍微向下推窗口。这可以通过以下方法来防止:
字符串
从
ViewControllerZ
上的事件返回到ViewControllerA
pnwntuvh2#
您可能已经在Interface Builder或XIB文件中选择了一些顶部栏,并额外设置了导航栏。不要在XIB文件中选择任何顶栏。
yqhsw0fo3#
尝试如下
字符串
yfjy0ee74#
经过长时间的研究,我终于解决了这个问题,只是从
UINavigationController
继承了这个类,而不是UIViewControler
。