Pregunta

Ya leo esta pregunta QlpreviewController Eliminar o agregar uibarbuttonitems Pero no es lo que estoy buscando. Me gustaría Mantenga el botón "Imprimir" en la barra de navegación pero también agregar Un nuevo botón "Eliminar documento" en la barra de navegación.

Intenté esto:

QLPreviewController *previewer = [[[QLPreviewController alloc] init] autorelease];
[previewer setDataSource:self];

UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]initWithTitle:@"Salva Documento" style:UIBarButtonItemStyleBordered target:self action:@selector(saveFileToDocuments)];
NSArray *buttons = [NSArray arrayWithObjects:[[previewer navigationItem]rightBarButtonItem],saveButton, nil];
[[previewer navigationItem]setRightBarButtonItems:buttons];

Pero no funcionó.

¿Fue útil?

Solución

Porque dijiste "4.x estará bien", está tu problema.

La documentación para UINavigationItem [setRightBarButtonItems: animated:] (documentina vinculada allí para usted) Dice que esta función solo funciona en iOS 5.0 y más nueva.

Va a no Trabaja en iOS 4.0.

Además, debes agregar un animated: parámetro a eso setRightBarButtonItems: llamar.

Otros consejos

    UIBarButtonItem *rbb;
-(void)addRightButton{
    if (!rbb) {
        UIButton *orderButton = [UIButton buttonWithType:UIButtonTypeCustom];
        orderButton.frame = CGRectZero;
        rbb = [[UIBarButtonItem alloc] initWithCustomView:orderButton];
    }

    self.navigationItem.rightBarButtonItem = rbb;
}

- (void)viewDidLoad{
    [super viewDidLoad];
    [self performSelector:@selector(addRightButton) withObject:nil afterDelay:0.2];
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self addRightButton];

}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top