iphone-dev:TabBarItem 帮助

发布于 2024-08-05 18:46:53 字数 713 浏览 5 评论 0原文

我正在像这样设置我的应用程序(在 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 文件。

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

I have am setting up my application like so (in 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];

where MyTableController extends UITableController and has a navigation controller property. tabBarController is an outlet via the main nib file. There are no other nib files.

I am now unable to add any buttons to the navigation controller. Everything I do is ignored. What am I doing wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无妨# 2024-08-12 18:46:53

您可以包含设置 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];

Can you include the code where you set up the UITabBarController tabBarController? I'm guessing that you are not properly setting the viewControllers property. Use UITabBarController -setViewControllers:animated: with an array of view controllers to initialize the tab bar controller.

Try something like this:

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文