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 841727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:50:46+00:00 2026-05-15T05:50:46+00:00

I am working on an iPhone application. Application has a navigation bar at the

  • 0

I am working on an iPhone application. Application has a navigation bar at the top. I have two views say “View1” and “View2”. When you push “View2” view controller the navigation bar shows a back button with the title of the “View1” so you can go back to view1.

Now my question is which event is fired when you click that button? Also is it possible to change the text of that back button in navigation bar?

Any help will be greatly appreciated?

Thanks

  • 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-15T05:50:47+00:00Added an answer on May 15, 2026 at 5:50 am

    There’s no specific event you can get just for that back button. You can use various viewWillAppear:, viewWillDisappear:, etc. methods instead. eg:

    //In View2:
    - (void) viewWillDisappear:(BOOL) animated {
        [super viewWillDisappear:animated];
        if (!goingToSubscreen) {
            //Do something important here
        }
        goingToSubscreen = NO;
    }
    
    //In View1:
    - (void) viewWillAppear:(BOOL) animated {
        [super viewWillAppear:animated];
        if (wentToSubscreen) {
            //Do something important here
        }
        wentToSubscreen = NO;
    }
    

    Note that the booleans wentToSubscreen and goingToSubscreen should be set up as named. If you are pushing another view onto the navigation controller on top of View2, you should set goingToSubscreen to YES so that it doesn’t do the important stuff. Conversely, you should set wentToSubscreen to YES on View1 after pushing View2, so that when it appears again, it’s after coming back from that screen that something interesting happens, and not when View1 initially appears.

    Edit:
    As of iOS 5.0, I believe there are built-in properties for this. isBeingDismissed is set to YES during viewWillDisappear: and viewDidDisappear: in the case that you press the back button. For reference, the properties you can check are:

    isMovingFromParentViewController
    isMovingToParentViewController
    isBeingPresented
    isBeingDismissed
    

    As for changing the title of the back button, the property belongs to the previous view’s back button item:

    View1.navigationItem.backBarButtonItem.title = @"My New Title";
    

    or:

    View1.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"New Title" style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
    

    Your third option is to use a custom button to replace the back button. It will let you specify your own method to call so you don’t need to use -viewWillDisappear:, but doing this will show the button as a rectangle instead of a back arrow button. This button goes on View2 instead of View1:

    View2.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"New Title" style:UIBarButtonItemStyleDone target:self action:@selector(dismissView)] autorelease];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.