我试图让一个基于导航的功能显示不同的表视图,没有运气。本质上用于initWithRootViewController
的视图没有正确显示,但导航栏是。下面是与层次TimerViewController
的viewDidLoad
方法中的代码AppDelegate
- >ViewController
- >TimerViewController
:UINavigationController initWithRootViewController,视图不出现
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中编写代码?或者你想通过点击导航来显示你的视图? – Alex 2012-07-31 14:43:32
该代码是在'TimerViewController'的'viewDidLoad'方法内的另一个具有'AppDelegate' - >'ViewController' - >'TimerViewController'类的类中编写的。 – 2012-07-31 14:52:11
你想要达到什么目的?带有栏的视图控制器,它是如何调用的?当你点击一个按钮? – Alex 2012-07-31 14:55:25