Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:39:30+00:00 2026-05-25T16:39:30+00:00

How do I pop up an UIAlertView when the back button of a UINavigationBar

  • 0

How do I pop up an UIAlertView when the back button of a UINavigationBar (controlled by a UINavigationController) was tapped? Under certain conditions, I want to ask the user an “Are you sure?” type of question so he could either abort the action and stay on the current view or pop the navigation stack and go to the parent view.

The most appealing approach I found was to override ShouldPopItem() on UINavigationBar’s Delegate.

Now, there is a quite similar question here: iphone navigationController : wait for uialertview response before to quit the current view

There are also a few other questions of similar nature, for example here:
Checking if a UIViewController is about to get Popped from a navigation stack?
and How to tell when back button is pressed in a UINavigationControllerStack

All of these state “subclass UINavigationController” as possible answers.

Then there is this one that reads like subclassing UINavigationController is generally not a good idea:
Monotouch: UINavigationController, override initWithRootViewController

The apple docs also say that UINavigationController is not intended to be subclassed.

A few others state that overriding ShouldPopItem() is not even possible when using a UINavigationController as that does not allow to assign a custom/subclassed UINavigationBarDelegate to the UINavigationBar.

None of my attempts of subclassing worked, my custom Delegate was not accepted.

I also read somewhere that it might be possible to implement ShouldPopItem() within my custom UINavigationController since it assigns itself as Delegate of its UINavigationBar.

Not much of a surprise, this didn’t work. How would a subclass of UINavigationController know of the Methods belonging to UINavigationBarDelegate. It was rejected: “no suitable method found to override”. Removing the “override” keyword compiled, but the method is ignored completely (as expected). I think, with Obj-C one could implement several Protocols (similar to Interfaces in C# AFAIK) to achieve that. Unfortunately, UINavigationBarDelegate is not an Interface but a Class in MonoTouch, so that seems impossible.

I’m pretty much lost here. How to override ShouldPopItem() on UINavigationBar’s Delegate when it is controlled by a UINavigationController? Or is there any other way to pop up an UIAlertView and wait for it’s result before possibly popping the navigation stack?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:39:31+00:00Added an answer on May 25, 2026 at 4:39 pm

    For reference, the route I took after giving up on ShouldPopItem() is to replace the back button with a UIBarButtonItem that has a custom UIButton assigned as it’s CustomView. The UIButton is crafted to look like the original back button using two images for the normal and the pressed state. Finally, hiding the original back button is required.

    Way too much code for what it’s supposed to do. So yeah, thanks Apple.

    BTW: Another possibility is creating a UIButton with the secret UIButtonType 101 (which is actually the back button) but I avoided this as it may break at any later iOS version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I pop up a UIAlertView to ask the user if they really want to
I have a button and when its clicked/tapped I want to check that a
I want to show a button name on it's click that pop's up a
I want to pop up a dialog box that says Saving... and once the
I want to pop up a form in C# .net 2.0 which should be
I'm trying to get a Loading UIAlertView with ActivityIndicator to pop up as soon
How to create a pop up animation on iPhone? I want show my uiview
I have made a custom UINavigationController class so that I can have a UIAlertView
In the tableview the user can tap the upper right button (navigation bar rightside)
I have a pop-up window from an exiting application that I want to trap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.