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

  • Home
  • SEARCH
  • 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 8585649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:07:07+00:00 2026-06-11T22:07:07+00:00

I am creating a view controller that is pushed to the UINavigationController . I

  • 0

I am creating a view controller that is pushed to the UINavigationController. I need a customized navigation bar, therefore I have overridden navigationItem method of my view controller. In a titleView (property of UINavigationItem) I need a custom view that holds two buttons. Question: how to apply view controller for those two buttons?

View containing two buttons is defined in CustomTitleViewController.xib, whereas its view controller is defined in CustomTitleViewController class.

This is my way of returning the navigation item (MainViewController.m):

- (UINavigationItem *)navigationItem
{
    UINavigationItem *navItem = [[UINavigationItem alloc] init];

    UIViewController *customTitleViewController =
        [[CustomTitleViewController alloc] initWithNibName:@"CustomTitleViewController"
                                                    bundle:[NSBundle mainBundle]];

    navItem.titleView = [customTitleViewController view];

    return navItem;
}

The view is shown on the navigation bar, as expected. However, tapping the button crashes the application (EXC_BAD_ACCESS).

Error message: message sent to deallocated instance 0x6e53850.

Any ideas?

  • 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-06-11T22:07:08+00:00Added an answer on June 11, 2026 at 10:07 pm

    Basically, you need to retain pointer to viewController as well as to its view. Just create strong property on your UINavigation controller subclass. Coz what you are doing here is instantiating new controller each time navigation item is called and realising it at the end of the function. Here is a very quick crude fix:
    https://www.dropbox.com/s/y6ltdyj951ioncd/Navigating.zip
    be sure not to reinstantiate VC all the time and keep pointer to it.
    Hope this helped.

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

Sidebar

Related Questions

I have an app that has a UINavigationController that pushes a UITabBarController into view.
When creating a new view controller to be pushed onto the stack, what is
I'm current creating a UISegmentedControl programmatically in a view controller's viewDidLoad method and adding
I am creating a view controller that will be used to enter text information.
I have a modal view controller that is displayed using: [self presentModalViewController:addStoryItem animated:YES]; on
I have a view controller (EmbeddedMenuView) that uses a custom view (HorizontalMenuView). The Embedded
I have a View Controller that is swapping UIView objects in and out. There
I am programmatically creating a view in the loadView method of my view controller.
I am creating an SDK for a client that includes predefined view controllers. What
Can rails handle creating a view without a controller? For example, let say I

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.