문제

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?

도움이 되었습니까?

해결책

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];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top