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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:44:42+00:00 2026-05-25T18:44:42+00:00

We have a controller that might be pushed from several places, so its back

  • 0

We have a controller that might be pushed from several places, so its back button might have one of several titles. It also has a button that pops up another controller. They both have the same custom title element, but they’re centred differently because the second controller has no back button. I’d like to add a spacer to fix this, but I don’t know what width to make it. How do I get the width of the back button in a UINavigationBar?

  • 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-25T18:44:43+00:00Added an answer on May 25, 2026 at 6:44 pm

    You could always spelunk through the navigation bar’s subviews, looking for the back button view and picking off the size when you find it. I did a blog post a while back on iterating through subviews of a UIView, here is the URL:

    http://www.dosomethinghere.com/2011/07/09/logging-the-view-hierarchy/

    I am using the InspectView class described in the above URL in my current app, and when I inserted this code into a view controller that has a back button in the navigation bar:

    - (void)viewDidAppear:(BOOL)animated
    {
        [InspectView dumpViewToLog:self.navigationController.navigationBar findParent:NO];
    }
    

    This is the resulting output in the console:

    2011-09-20 09:11:19.599 MyApp[2070:207] 
    Inspect view hierarchy -----------------------------------
    UINavigationBar (0x6626460): frame origin: (0, 20) size: (320, 44) [tag=0] UIView : UIResponder : NSObject : 
    .   UILabel (0x6613f00): frame origin: (62, 0) size: (200, 44) [tag=0] UIView : UIResponder : NSObject : 
    .   .   UILabel (0x6628520): frame origin: (0, 19) size: (200, 20) [tag=0] UIView : UIResponder : NSObject : 
    .   .   UILabel (0x665eda0): frame origin: (0, -1) size: (200, 24) [tag=0] UIView : UIResponder : NSObject : 
    .   UINavigationItemButtonView (0x662a5b0): frame origin: (5, 7) size: (49, 30) [tag=0] UINavigationItemView : UIView : UIResponder : NSObject : 
    End of view hierarchy -----------------------------------
    

    The UINavigationItemButtonView is the back button, and you can see that the size if 49 wide by 30 tall. You would look for this view class in your app and remember the size.

    Please keep in mind that putting this code into viewDidLoad or viewWillAppear will show different results.

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

Sidebar

Related Questions

--Summary (shortened)-- I have a controller that loads a profile object from the corresponding
I have a controller method that returns a jSON object and in one calling
My base controller has: [Authorize(Roles = sys_admin)] I want to have one action in
I have a controller action that aggregates data from multiple sources: web service, database,
Reasonably new to MVC. My problem is that I have a controller that has
This might be extremely simple: I have a controller that returns a user object
I have a controller that contains a tableView that spawns another controller modally to
I have a controller that is called with AJAX (sends JSON data), so I
When you have a controller that does logic with services and DAO's that may
I have a controller action that is being executed by a link that was

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.