【问题标题】:How to add 5 button on NavigationBar如何在 NavigationBar 上添加 5 个按钮
【发布时间】:2011-08-01 02:33:26
【问题描述】:

如何在 UINavigation 栏上添加大约 5 个按钮。

我很好,我们可以为导航添加左右按钮

使用 UIToolbar 我们在导航栏上添加按钮。

是任何其他适合导航栏周围五个按钮的方式。接受苹果的地方

【问题讨论】:

    标签: iphone objective-c


    【解决方案1】:

    您始终可以使用[self.navigationController.navigationBar addSubview: abutton];

    【讨论】:

      【解决方案2】:
      NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:5];
      
      // create a standard "1" button
      UIBarButtonItem* bi = [[UIBarButtonItem alloc]
      initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:NULL];
      bi.style = UIBarButtonItemStyleBordered;
      [buttons addObject:bi];
      [bi release];
      
      //for spacer
      bi = [[UIBarButtonItem alloc]
      initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
      [buttons addObject:bi];
      [bi release];
      
      // create a standard "2" button
      bi = [[UIBarButtonItem alloc]
      initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)];
      bi.style = UIBarButtonItemStyleBordered;
      [buttons addObject:bi];
      [bi release];
      
      // and so on you can create rest button in the same way and add to tools
      // stick the buttons in the toolbar
      [tools setItems:buttons animated:NO];
      [buttons release];
       // and put the toolbar in the nav bar
       self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]   initWithCustomView:tools];
      [tools release];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-10
        相关资源
        最近更新 更多