QLPreviewController удалить или добавить UIBarButtonItems

Я много видел такого рода вопросы в Интернете, но кажется, никто не знает ответа?

Я использую QLPreviewController для отображения документов PDF. Сначала я использовал UIWebView, но мне порекомендовали использовать QLPreviewController вместо этого по соображениям производительности с более крупными документами.

я хочу 4 пользовательских элемента UIBarButtonItem в правом верхнем углу (так, где кнопка печати).

Мне удалось получить настраиваемая панель инструментов внизу, но это не совсем то, что я хочу.

Учитывая, что невозможно добавить настраиваемую кнопку вместо кнопки печати, я все же хочу удалить кнопку печати и использовать вместо нее настраиваемую панель инструментов.

РЕДАКТИРОВАТЬ (Решение): Я нашел решение некоторое время назад, но не обновлял этот пост, поэтому вот как я решил проблему:

Я добавляю все кнопки вручную:

// Create a toolbar to have the buttons at the right side of the navigationBar
UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 180, 44.01)];
[toolbar setTranslucent:YES];

// Create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:4];


// Create button 1
button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(button1Pressed)];
[buttons addObject:button1];

// Create button 2
button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(button2Pressed)];
[buttons addObject:button2];

// Create button 3
button3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(button3Pressed)];
[buttons addObject:button3];

// Create a action button
openButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(openWith)];
[buttons addObject:openButton];

// insert the buttons in the toolbar
[toolbar setItems:buttons animated:NO];

// and put the toolbar in the navigation bar
[[self navigationItem] setRightBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:toolbar]];
16
задан Justin 25 September 2012 в 08:50
поделиться