そのため、テーブルビューを含む 1 つのページが必要なビューベースのアプリがあり、その上に戻るナビゲーション バーが必要でした。これをプログラムで追加しました:
-(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 を変更できないため、これに問題があります。ナビゲーションバーが上から下に非常に細くなることを除いて、テーブルビューページ全体がうまくサイズ変更されます。高さはそのままでいいと思います。適切なマスクを設定したり、IB 外のナビゲーション バーにアクセスするにはどうすればよいですか?