Objective c 如何在ios7中将多个UIBarButtonItem添加到rightBarButtonItem?
我有一个在ios6中运行良好的现有代码。但在ios7中,最左边的itemrefresh按钮并没有显示与其他两个UIBarButtonItem对齐。它有点低落。下面是iOS6的代码。我需要做哪些更改才能使它在iOS7中工作Objective c 如何在ios7中将多个UIBarButtonItem添加到rightBarButtonItem?,objective-c,ios7,uibarbuttonitem,xcode5,rightbarbuttonitem,Objective C,Ios7,Uibarbuttonitem,Xcode5,Rightbarbuttonitem,我有一个在ios6中运行良好的现有代码。但在ios7中,最左边的itemrefresh按钮并没有显示与其他两个UIBarButtonItem对齐。它有点低落。下面是iOS6的代码。我需要做哪些更改才能使它在iOS7中工作 // create an array for the buttons NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3]; // create a standard save butto
// create an array for the buttons
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
// create a standard save button
UIBarButtonItem* refreshButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(refreshButtonClicked:)];
refreshButton.style=UIBarButtonItemStyleBordered;
//self.navigationItem.rightBarButtonItem = refreshButton;
[buttons addObject:refreshButton];
[refreshButton release];
// create a spacer between the buttons
UIBarButtonItem *spacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
[buttons addObject:spacer];
[spacer release];
// create a standard delete button with the trash icon
UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoDark];
[button setFrame:CGRectMake(0, 0, 30, 30)];
[button addTarget:self action:@selector(InfoButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
infoItem = [[UIBarButtonItem alloc] initWithCustomView:button];
[buttons addObject:infoItem];
// put the buttons in the toolbar and release them
[toolbar setItems:buttons animated:NO];
[buttons release];
// place the toolbar into the navigation bar
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
initWithCustomView:toolbar]autorelease];
谢谢试试:
self.navigationItem.rightBarButtonItems=按钮 试试看:
self.navigationItem.rightBarButtonItems=按钮 谢谢你,利奥。下面这行代码为我解决了这个问题。self.navigationItem.RightBarButtonims=[NSArray arrayWithObjects:refreshButton,infoItem,nil];谢谢你,利奥。下面这行代码为我解决了这个问题。self.navigationItem.RightBarButtonims=[NSArray arrayWithObjects:refreshButton,infoItem,nil];