1

我正在像这样设置我的应用程序(在 applicationDidFinishLaunching 中):

mytable = [[[MyTableController alloc] initWithStyle:UITableViewStylePlain] retain];

UINavigationController *mynav =  [[[UINavigationController alloc]initWithRootViewController:mytable] autorelease];

[mynav.view setFrame:CGRectMake(0,0,320,460)];

UIViewController *tab1 = [[tabBarController viewControllers] objectAtIndex:0];

[mytable setTitle:@"Chronological"];

mytable.navigationController = mynav;

[tab1.view addSubview:mynav.view];

[window addSubview:tab1.view];

其中 MyTableController 扩展 UITableController 并具有导航控制器属性。tabBarController 是一个通过主 nib 文件的出口。没有其他 nib 文件。

我现在无法向导航控制器添加任何按钮。我所做的一切都被忽略了。我在这里做错了什么?

4

1 回答 1

0

您可以在其中设置代码UITabBarController tabBarController吗?我猜你没有正确设置viewControllers属性。UITabBarController -setViewControllers:animated:与视图控制器数组一起使用来初始化标签栏控制器。

尝试这样的事情:

mytable = [[MyTableController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *mynav = [[UINavigationController alloc] initWithRootViewController:mytable];
[tabBarController setViewControllers:[NSArray arrayWithObject:mynav] animated:NO];
[mynav release];
[mytable release];
[tabBarController viewWillAppear:NO];
[window addSubview:[tabBarController view]];
[tabBarController viewDidAppear:NO];
于 2009-09-25T18:01:13.617 回答