iphone-dev:TabBarItem 帮助
我正在像这样设置我的应用程序(在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以包含设置
UITabBarController
tabBarController
的代码吗?我猜测您没有正确设置viewControllers
属性。使用UITabBarController -setViewControllers:animated:
和视图控制器数组来初始化选项卡栏控制器。尝试这样的事情:
Can you include the code where you set up the
UITabBarController
tabBarController
? I'm guessing that you are not properly setting theviewControllers
property. UseUITabBarController -setViewControllers:animated:
with an array of view controllers to initialize the tab bar controller.Try something like this: