所以我有一个基于视图的应用程序,其中我需要一个带有表格视图的页面,并且我希望它上方的导航栏返回。我以编程方式添加了这个:
-(IBAction)switchToTableView; {
tableView *table = [[tableView alloc] initWithNibName:@"tableView" bundle:nil];
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: table];
table.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[table release];
[self presentModalViewController: navControl animated:YES];
[navControl release];
}
然后在我实现的tableview类的viewDidLoad中:
- (void)viewDidLoad
{
self.tableView.rowHeight = 70.f;
UIBarButtonItem *back = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleDone
target:self
action:@selector(switchToHome)];
self.navigationItem.leftBarButtonItem = back;
UIBarButtonItem *map = [[UIBarButtonItem alloc]
initWithTitle:@"Map"
style:UIBarButtonItemStyleDone
target:self
action:@selector(switchBacktoFindArt)];
self.navigationItem.rightBarButtonItem = map;
[map release];
[super viewDidLoad];
}
添加所需的按钮。现在,所有这一切都很好,但是现在我正在浏览我的应用程序并允许更改方向,我遇到了这个问题,因为我无法更改 IB 中的 autoresizingMask。整个 tableview 页面可以很好地调整大小,除了导航栏从上到下变得非常瘦。我希望它保持相同的高度。如何设置适当的掩码甚至访问 IB 之外的导航栏?