User behavior when clicking the back button in the navigation bar

I know that you can add a custom back button to the UINavigationBar, but it deletes the existing button with a tapered left side, as described in What happens when the back button is pressed in the navigationBar

Is there a way to preserve the existing behavior and appearance of the back button, but also be informed when clicked?

Basically, I want my application to play sound when any button is pressed. I can do this using the UITabBarController through its delegate, but the delegate for the UINavgationBarController does not have such functions.

+3
source share
1

.

  • ( backBarButtonItem).
  • backBarButtonItem

viewWillDisappear:. . isAnyButtonClicked. isAnyButtonClicked = YES , . viewWillDisappear: , (.., isAnyButtonClicked == NO). , viewWillDisappear: ,

- (void)viewWillDisappear:(BOOL)animated {

    [super viewWillDisappear:animated];

    if (!isAnyButtonClicked) {

        // Play sound
        isAnyButtonClicked = NO;
    }
}
+3

Source: https://habr.com/ru/post/1790861/


All Articles