所以我的應用程序有一個UITabBarController。在其中,其中一個選項卡是包含UINavigationController的UIViewController。在那裏是一個UITableViewController。如何在UITabBarViewController中的UINavigationController中調整UITableView的大小?
問題是,由於某種原因,TableView的大小已關閉,並且表格的底部條目的一部分被TabBar遮擋。我嘗試了所有我能想到的調整tableview的大小,但無濟於事。下面是代碼的相關部分:
的AppDelegate
tabBarController = [[UITabBarController alloc] init];
LogbookViewController *firstVC = [[LogbookViewController alloc] init];
PaceCalcViewController *secondVC = [[PaceCalcViewController alloc] init];
SettingsTableViewController *thirdVC = [[SettingsTableViewController alloc] init];
...
// Add them as children of the tab bar controller
tabBarController.viewControllers = [NSArray arrayWithObjects: firstVC, secondVC, thirdVC, nil];
LogbookViewController(UIViewController的子類)
- (void)viewDidLoad {
[super viewDidLoad];
navigationController = [[UINavigationController alloc] init];
[self.view addSubview:navigationController.view];
WorkoutListTableViewController *listController = [[WorkoutListTableViewController alloc] init];
listController.managedObjectContext = self.managedObjectContext;
[navigationController pushViewController:listController animated:NO];
[listController release];
}
的WorkoutListTableViewController(的UITableViewController的子類)目前沒有特別的事情我認爲會影響它,但這裏是ViewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Workouts";
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"List" style:UIBarButtonItemStyleBordered target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
NSString *paths = [[NSBundle mainBundle] resourcePath];
NSString *fileName = @"short_bg.png";
NSString *filePath = [paths stringByAppendingPathComponent:fileName];
UIImage *paper = [[UIImage alloc] initWithContentsOfFile:filePath];
UIImageView *paper_bg = [[UIImageView alloc] initWithImage:paper];
self.tableView.backgroundView = paper_bg;
[fileName release];
[paper release];
//self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
self.navigationItem.rightBarButtonItem = addButtonItem;
[addButtonItem release];
/*UIBarButtonItem *importButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Import" style:UIBarButtonItemStylePlain target:self action:@selector(importDialogAction:)];
self.navigationItem.leftBarButtonItem = importButtonItem;
[importButtonItem release];*/
}
}
我已經嘗試過像LogViewViewController中的listController.view.frame = CGRectMake(無論),或WorkoutListTableViewController中的self.tableView.frame - CGRectMake(無論),但沒有任何工作。有任何想法嗎?如果有幫助,我可以發佈更多的代碼。
這樣做的問題是我希望標籤標題和導航欄標題不同。有沒有辦法單獨定義它們?另外,我創建單獨的視圖控制器的部分原因是因爲我有一個模式視圖控制器,我想要在表格上方顯示,但在標籤欄之下,這樣當模式視圖出現時,選項卡欄保持可見。有沒有額外的子視圖做到這一點的另一種方法? – 2011-02-03 18:10:25