所以,我的iPad程序有一個僞分割視圖控制器(我實現了一個,而不是基礎SDK一個),並且前一陣子工作正常。它具有基本的佈局(主控制器的UINavController,右側的內容視圖控制器),但是我擁有它,所以當旋轉到縱向視圖時,主視圖不會消失。UINavigationController導航欄沒有正確定位
最近,我在一個的UITabBarController添加到包含整個拆分視圖,這使得導航欄去靠不住的,而所有其他的意見被定位罰款。此外,當iPad處於橫向或倒置縱向時,導航欄僅在程序啓動時錯位。如果從肖像開始,一切都很好。
實施例的圖像可以在這裏找到: http://profile.imageshack.us/user/Pzychotix
圖像,其中所述導航欄是向上是當我最初啓動該程序。 導航欄向下的圖像是在我旋轉一次或多次之後。
相關代碼:
RootViewController.m:
- (void)loadView {
navController = [[NavigationBreadcrumbsController_Pad alloc] init];
ABTableViewController_Pad * tableViewController = [[ABTableViewController_Pad alloc] initWithNibName:@"ABTableView"];
master = [[UINavigationController_Pad alloc] initWithRootViewController:tableViewController];
[tableViewController release];
// Dummy blank UIViewcontroller
detail = [[UIViewController alloc] init];
detail.view = [[[UIView alloc] init] autorelease];
[detail.view setBackgroundColor:[UIColor grayColor]];
self.view = [[[UIView alloc] init] autorelease];
self.view.backgroundColor = [UIColor blackColor];
[self positionViews];
[self.view addSubview:navToolbarController.view];
[self.view addSubview:master.view];
[self.view addSubview:detail.view];
}
// Handles the respositioning of view into it's current orientation
-(void)positionViews{
CGFloat tabBarOffset = 0;
if(self.tabBarController){
tabBarOffset = self.tabBarController.tabBar.frame.size.height;
}
if(self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
self.view.frame = CGRectMake(0, 0, 768, 1004);
navController.view.frame = CGRectMake(0,0,768,44);
//adjust master view
[master.view setFrame:CGRectMake(0, 44, 320, 1024 - 44 - 20 - tabBarOffset)];
//adjust detail view
[detail.view setFrame:CGRectMake(321,44, 448, 1024 - 44 - 20 - tabBarOffset)];
}
// Landscape Layout
else{
self.view.frame = CGRectMake(0, 0, 748, 1024);
navToolbarController.view.frame = CGRectMake(0,0,1024,44);
//adjust master view
[master.view setFrame:CGRectMake(0, 44, 320, 768 - 44 - 20 - tabBarOffset)];
//adjust detail view
[detail.view setFrame:CGRectMake(321,44, 1024 - 320, 768 - 44 - 20 - tabBarOffset)];
}
}
它是如何錯位的? – rickharrison 2010-05-26 18:03:34
我已經添加了新的示例圖像。 – 2010-05-26 22:17:47