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