【发布时间】:2012-07-31 14:32:47
【问题描述】:
我正在尝试获得基于导航的功能来显示不同的表格视图,但没有成功。本质上,用于initWithRootViewController 的视图没有正确显示,但导航栏是。这是TimerViewController 的viewDidLoad 方法中的代码,其层次结构为AppDelegate -> ViewController -> TimerViewController:
incidentTableViewController = [[IncidentTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
[incidentTableViewController.tableView.backgroundView setBackgroundColor:[UIColor colorWithRed:167.0/255.0 green:169.0/255.0 blue:172.0/255.0 alpha:1.0]];
[incidentTableViewController.view setFrame:CGRectMake(0, 0, 268, 423)];
[incidentTableViewController.tableView showsVerticalScrollIndicator];
[incidentTableViewController setTitle:@"Incidents"];
[incidentTableViewController.navigationController setNavigationBarHidden:NO];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:incidentTableViewController];
[controller.view setFrame:CGRectMake(268, 0, 268, 423)];
[controller.view setBackgroundColor:[UIColor clearColor]];
[controller.navigationController setNavigationBarHidden:YES];
//[controller.view addSubview:incidentTableViewController.view];
[self.view addSubview:controller.view];
这会导致(我也不确定导航栏上方为什么会有空隙):
如果我取消注释倒数第二行 [controller.view addSubview:incidentTableViewController.view]; 我会得到这个结果,这是减去导航栏所需的结果:
我想要实现的是第二张带有导航栏的图片,有什么想法吗?
【问题讨论】:
-
您在 appDelegate 中使用哪种方法编写代码?还是您想通过点击显示您的视图?
-
代码写在另一个类中,层次结构为
AppDelegate->ViewController->TimerViewController在viewDidLoad的viewDidLoad方法中TimerViewController。 -
你想要实现什么?带bar的viewcontroller,怎么叫?当你点击一个按钮?
-
我希望用导航栏显示第二张图片(表格视图显示正确)
-
这个带有工具栏的视图是你的初始视图(当应用启动时你首先看到它)?
标签: ios ipad uinavigationcontroller uitableview