Add 2 UIButtons to a UINavigationBar right item

转载 2012年03月30日 10:50:45

// create a toolbar to have two buttons in the right
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 90.0, 44.01)];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];
// create a standard "add" button
UIButton *btnAdd = [[UIBarButtonItem alloc]
		  initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add)];
[buttons addObject:btnAdd];
[btnAdd release];
// create a "edit" button
UIButton *btn = [[UIBarButtonItem alloc]
		  initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self action:@selector(edit)];
[buttons addObject:btnEdit];
[btnEdit release];
// 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];


Add Custom Background Image to UINavigationBar in iOS 5

From iOS 5, Apple has officially supported adding custom background image to theUINavigationBar with...
  • xdrt81y
  • xdrt81y
  • 2013年05月29日 13:11
  • 2440


1.add_to_collection add_to_collectio为Graph的一个方法,可以简单地认为Graph下维护了一个字典,key为name,value为list,而add_to_co...

Add a Node to Oracle RAC 11gR2( on Oracle Linux 6

Delete a Node from Oracle RAC 11gR2( on Oracle Linux 6 This guide shows how to add a...

Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify pr

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService'...

cocos2之How to add a sprite (2)

原文参看: 2 添加一个一个小精灵 ...

effective C++ (Item2) Prefer <iostream> to <stdio.h>

type safety and extensibility are cornerstones of the C++ way of life.  int i; Rational r; cin >>...

Effective C++ (3rd Ed) 读书笔记(一)Item 2: Prefer constS, enumS, and inlineS to #defineS

您举报文章:Add 2 UIButtons to a UINavigationBar right item