将ToolBar添加到UITableView的正确方法是什么? [英] What's the right way to add a ToolBar to a UITableView?

查看:81
本文介绍了将ToolBar添加到UITableView的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个基于导航的iPhone应用程序,我希望UIToolBar停靠在屏幕底部,UITableView在工具栏和导航栏之间滚动。

I'm writing a Navigation-Based iPhone app, and I'd like to have a UIToolBar docked at the bottom of my screen, with a UITableView scrolling between the tool bar and the navigation bar.

我见过几个论坛,建议处理此视图的View Controller应该是标准的UIViewController,而不是UITableViewController。除了所有标准的UIViewController重写之外,视图控制器还必须实现UITableView委托和数据源方法。除了前面提到的协议之外,我需要在这个视图控制器子类中重新创建什么(如果有的话)内置功能才能让它像UITableViewController一样工作?通过这条路线我有什么损失吗?

I've seen a couple of forums where it's been suggested that the View Controller handling this view should be a standard UIViewController rather than a UITableViewController. The view controller would have to implement the UITableView delegate and data source methods in addition to all of the standard UIViewController overrides. What (if any) built-in functionality do I need to recreate in this view controller subclass other than the aforementioned protocols to have it act like a UITableViewController? Is there anything I'm losing by going this route?

或者在标准的UIViewController中嵌入UITableViewController会更好吗?

Or would it be better to nest a UITableViewController inside of a standard UIViewController?

推荐答案

从OS 3.0开始,导航控制器内置了一个工具栏。要显示它:

As of OS 3.0 the Navigation Controller has a tool bar built in. To make it appear:

[self.navigationController setToolbarHidden:NO];

通过implmenting:

By implmenting:

- (void)setToolbarItems:(NSArray *)toolbarItems animated:(BOOL)animated

在视图控制器中,您可以配置工具栏的项目。

in your view controller, you can configure the items of the tool bar.

因此您不必再担心工具栏在层次结构中的位置。

So you no longer have to worry about where the tool bar is located in your hierarchy.

(更正错字)

这篇关于将ToolBar添加到UITableView的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆