iPhone SDK问题:在TabBarControlled Views中加载TableView
我遇到了一个问题,现在一整天都找不到解决方案。我是 iPhone SDK 的新手,所以我想我只是错过了一些东西。
我的应用程序由 TabbedNavigation 组成,具有三个 ViewController。一切都按预期进行。现在,当用户点击按钮(而不是选项卡按钮...)时,我想打开一个新视图(最好是从 NIB)。按钮的操作方法按预期调用。但是,我没有加载新的(表)视图。
我尝试给你一些代码来解释我的情况:
首先,在我的应用程序的委托的 didFinishLaunchingWithOptions 中,我加载 tabBarController 的视图(TabBarController 是委托的属性):
// Add the tab bar controller's view to the window and display.
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
当应用程序启动时,会显示 TabController 的第一个 ViewController,如下所示预期的。该 viewController 有其自定义 ViewController 类,其中包含按钮的操作方法。我的操作方法如下所示:
-(IBAction)filtersButtonPressed:(id)sender {
FiltersTableViewController *filtersViewController =
[[FiltersTableViewController alloc] initWithNibName:@"Filters" bundle:nil];
[[[super tabBarController] navigationController] pushViewController:filtersViewController];
}
不知何故,这不起作用......我当然尝试了几件事 - 但没有成功。
你们中有人能指出我正确的方向吗?只需按一下按钮即可进入新视图并不是那么困难...
提前致谢!
谢尔·帕维
I've a problem and cannot find a solution to the whole day now. I'm new to iPhone SDK, so I guess I'm just missing something.
My app consists of a TabbedNavigation, having three ViewControllers. Everything works as expected. Now I want to open a new view (preferably from a NIB) when the user tabs a button (not the tab buttons...). The button's action method is called as expected. However, I don't get the new (table-)view loaded.
I try to give you some code that explains my situation:
First, in my Application's delegate's didFinishLaunchingWithOptions I load the tabBarController's view (the TabBarController is a property of the delegate):
// Add the tab bar controller's view to the window and display.
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
The first ViewController of the TabController is shown when the app is startet, as expected. This viewController has its custom ViewController class in which the action-method for the button sits. My action method looks like this:
-(IBAction)filtersButtonPressed:(id)sender {
FiltersTableViewController *filtersViewController =
[[FiltersTableViewController alloc] initWithNibName:@"Filters" bundle:nil];
[[[super tabBarController] navigationController] pushViewController:filtersViewController];
}
This, somehow, is not working... I have tried several things of course - with no success.
Can someone of you guys point me in the right direction? It cannot be that hard just to get to a new view by the press of a button...
Thanks in advance!
Chers, pawi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
建议您尝试将新的“过滤器”视图显示为模式视图控制器。尝试将代码更改为:
这会将过滤器视图控制器向上滑动到当前视图的顶部(尽管您可以根据需要更改动画效果)。要摆脱这个问题,当用户完成视图后,调用
编辑:
如果您确实想使用导航控制器将视图推送到堆栈上,请使用
Suggest you try showing the new "Filters" view as a modal view controller. Try changing your code to:
This will slide up the filters view controller (although you can change the animation effect if you want) on top of your current view. To get rid of this, when the user has finished with the view, call
Edit:
If you really want to use the navigation controller to push the view onto the stack, use