【发布时间】:2011-02-02 23:52:24
【问题描述】:
所以我的应用程序有一个 UITabBarController。其中,其中一个选项卡是包含 UINavigationController 的 UIViewController。其中有一个 UITableViewController。
问题是由于某种原因,TableView 的大小关闭了,并且表格底部条目的一部分被 TabBar 遮挡了。我已经尝试了我能想到的一切来调整表格视图的大小,但无济于事。以下是代码的相关部分:
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];*/
}
}
我在 LogbookViewcontroller 中尝试了 listController.view.frame = CGRectMake(whatever) 或 WorkoutListTableViewController 中的 self.tableView.frame - CGRectMake(whatever) 之类的方法,但没有任何效果。有任何想法吗?如果有帮助,我可以发布更多代码。
【问题讨论】:
标签: iphone ios uitableview ios4