<tfoot id='mJFdw'></tfoot>

    <legend id='mJFdw'><style id='mJFdw'><dir id='mJFdw'><q id='mJFdw'></q></dir></style></legend>

      <i id='mJFdw'><tr id='mJFdw'><dt id='mJFdw'><q id='mJFdw'><span id='mJFdw'><b id='mJFdw'><form id='mJFdw'><ins id='mJFdw'></ins><ul id='mJFdw'></ul><sub id='mJFdw'></sub></form><legend id='mJFdw'></legend><bdo id='mJFdw'><pre id='mJFdw'><center id='mJFdw'></center></pre></bdo></b><th id='mJFdw'></th></span></q></dt></tr></i><div id='mJFdw'><tfoot id='mJFdw'></tfoot><dl id='mJFdw'><fieldset id='mJFdw'></fieldset></dl></div>
        <bdo id='mJFdw'></bdo><ul id='mJFdw'></ul>

      <small id='mJFdw'></small><noframes id='mJFdw'>

      将工具栏添加到 UITableViewController

      时间:2023-06-10
      <tfoot id='IjcTu'></tfoot>
          <bdo id='IjcTu'></bdo><ul id='IjcTu'></ul>
        • <legend id='IjcTu'><style id='IjcTu'><dir id='IjcTu'><q id='IjcTu'></q></dir></style></legend>

              <small id='IjcTu'></small><noframes id='IjcTu'>

              <i id='IjcTu'><tr id='IjcTu'><dt id='IjcTu'><q id='IjcTu'><span id='IjcTu'><b id='IjcTu'><form id='IjcTu'><ins id='IjcTu'></ins><ul id='IjcTu'></ul><sub id='IjcTu'></sub></form><legend id='IjcTu'></legend><bdo id='IjcTu'><pre id='IjcTu'><center id='IjcTu'></center></pre></bdo></b><th id='IjcTu'></th></span></q></dt></tr></i><div id='IjcTu'><tfoot id='IjcTu'></tfoot><dl id='IjcTu'><fieldset id='IjcTu'></fieldset></dl></div>
                <tbody id='IjcTu'></tbody>

              1. 本文介绍了将工具栏添加到 UITableViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                将 UIToolBar 添加到 UITableViewController 的最简单方法是什么?我依赖于编辑功能,所以我不能轻易将 UITableViewController 更改为 UIViewController.

                What is the simplest way to add UIToolBar to UITableViewController? I'm depending on edit functionality, so I can't change UITableViewController to UIViewController easily.

                推荐答案

                没问题,UITableViewControllerUIViewController的子类.碰巧的是,在 iPhone OS 3.0 中,任何 UIViewController (和子类) 都可以与 UINavigationController 一起工作,以提供上下文感知工具栏.

                No problem at all, UITableViewController is a subclass of UIViewController. And it so happens that in iPhone OS 3.0 any UIViewController (and subclasses) can work in conjunction with a UINavigationController to provide a context aware toolbar.

                为了使其工作,您必须:

                In order for this to work you must:

                • 确保使用 UINavigationController 来包含所有需要工具栏的视图控制器.
                • 设置需要工具栏的视图控制器的 toolbarsItems 属性.
                • Make sure that you use a UINavigationController to contain all your view controllers that needs a toolbar.
                • Set the toolbarsItems property of the view controller that wants a toolbar.

                这几乎就像设置视图控制器的标题一样简单,并且应该以相同的方式完成.很可能通过覆盖 initWithNibName:bundle: 初始化程序.举个例子:

                This is almost as easy as as setting the view controller's title, and should be done the same way. Most probably by overriding the initWithNibName:bundle: initializer. As an example:

                -(id)initWithNibName:(NSString*)name bundle:(NSBundle*)bundle;
                {
                  self = [super initWithNibName:name bundle:bundle];
                  if (self) {
                    self.title = @"My Title";
                    NSArray* toolbarItems = [NSArray arrayWithObjects:
                        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
                                                                      target:self
                                                                      action:@selector(addStuff:)],
                        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch 
                                                                      target:self
                                                                      action:@selector(searchStuff:)],
                        nil];
                    [toolbarItems makeObjectsPerformSelector:@selector(release)];
                    self.toolbarItems = toolbarItems;
                    self.navigationController.toolbarHidden = NO;
                  }
                  return self;
                }
                

                您还可以使用 setToolbarItems:animated: 而不是分配给 toolbarItems 属性,以动态添加和删除工具栏项.

                You can also use setToolbarItems:animated: instead of assigning to the toolbarItems property, to add and remove toolbar items in an animated fashion on the fly.

                这篇关于将工具栏添加到 UITableViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:使用导航控制器在 Storyboard 中呈现视图控制器 - Swift 下一篇:在 Swift 中的 Nav Controller 中弹出 2 个视图控制器

                相关文章

                <i id='GWZlJ'><tr id='GWZlJ'><dt id='GWZlJ'><q id='GWZlJ'><span id='GWZlJ'><b id='GWZlJ'><form id='GWZlJ'><ins id='GWZlJ'></ins><ul id='GWZlJ'></ul><sub id='GWZlJ'></sub></form><legend id='GWZlJ'></legend><bdo id='GWZlJ'><pre id='GWZlJ'><center id='GWZlJ'></center></pre></bdo></b><th id='GWZlJ'></th></span></q></dt></tr></i><div id='GWZlJ'><tfoot id='GWZlJ'></tfoot><dl id='GWZlJ'><fieldset id='GWZlJ'></fieldset></dl></div>
              2. <tfoot id='GWZlJ'></tfoot>
              3. <small id='GWZlJ'></small><noframes id='GWZlJ'>

                    <legend id='GWZlJ'><style id='GWZlJ'><dir id='GWZlJ'><q id='GWZlJ'></q></dir></style></legend>

                    • <bdo id='GWZlJ'></bdo><ul id='GWZlJ'></ul>