Question

We have a custom QLPreviewController implementation, so we can control the buttons presented to the user, and their actions. I have added the following code to the viewWillAppear method of the custom class:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(openWithPressed:)];
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissPressed:)];
    [self.navigationItem setRightBarButtonItem:rightBarButtonItem];
    [self.navigationItem setLeftBarButtonItem:leftBarButtonItem];
    [rightBarButtonItem release];
    [leftBarButtonItem release];
}

the previewer does appear with our custom buttons, and they work as expected.
Our problem occurs when the user clicks on the "Home" button. It seams that the UIApplication.doEvents method calls the navigationItem set button methods, and resets them to the original values (with the original handlers).
How can I prevent this from happening, or handle those events myself, and overwrite them with my own custom buttons?

Was it helpful?

Solution

I had this same problem. You need to set up a NSNotification that gets called when the application becomes active again, and then reset the navigation bar to how you want it

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(configureNavBar)
                                             name:UIApplicationDidBecomeActiveNotification object:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top