1
我有一个现有的代码,这是在iOS6的工作的罚款。但在ios7中,最左边的项目(“刷新按钮”)未显示与其他两个UIBarButtonItem对齐。其显示有点下降。这里是iOS6的代码。我需要做什么改变才能在iOS7中工作。如何在ios7中添加多个UIBarButtonItem到rightBarButtonItem?
// 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 = [NSArray的arrayWithObjects:refreshButton,infoItem,零]。 – bhargava