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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:54:56+00:00 2026-05-25T13:54:56+00:00

I have an UIViewController with several subviews in its view property ( UISearchbar and

  • 0

I have an UIViewController with several subviews in its view property (UISearchbar and several UIButtons). The UIButtons hooked up to typical IBActions like -(IBAction)buttonPressed:(id)sender for the UIControlEventTouchUpInside state – it doesn’t matter if I do it in IB or programmatically.

- (void)viewDidLoad {
    MUZTitleViewController *title = [[MUZTitleViewController alloc] 
                                     initWithNibName:nil bundle:nil];
    self.navigationItem.titleView = title.view;
}

In my project there’s also an UINavigationController. When I set the navigationItem.titleView of the UINavigationBar to the view of my UIViewControllers view I get an EXC_BAD_ACCESS exception, as soon as I tap one of the button. I don’t know why this is.

I uploaded a small sample project to illustrate my problem: Test010.xcodeproj (it’s ARC enabled)

More and more I come to the conclusion that it’s not a good idea to use the UIViewControllers view and assign it to the titleView but I don’t see any alternative here.

Edit: Sorry, the sample project commented out the call which causes the exception. I reuploaded the linked project file.

Edit^2: As PengOne pointed out I’ve skipped the exact error message I got:

2011-09-10 23:09:50.621 Test010[78639:f803] -[CALayer buttonPressed:]: unrecognized selector sent to instance 0x9254ae0
2011-09-10 23:09:50.623 Test010[78639:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer buttonPressed:]: unrecognized selector sent to instance 0x9254ae0'
  • 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-25T13:54:57+00:00Added an answer on May 25, 2026 at 1:54 pm

    Have you tried setting NSZombieEnabled to YES? If I do this, the console shows the following output:

    2011-09-10 22:56:23.329 Test010[6481:ef03] *** -[MUZTitleViewController
    performSelector:withObject:withObject:]: message sent to deallocated 
    instance 0x7a7ff70
    

    As the project is ARC enabled, the controller seems to get deallocated some time after this line:

    MUZTitleViewController *title = [[MUZTitleViewController alloc] initWithNibName:nil bundle:nil];
    

    I am not sure what the best solution is, but a property definitely helps to prevent the exception like so:

    // MUZDetailViewController.h
    @property (strong, nonatomic) MUZTitleViewController *title;
    
    // MUZDetailViewController.m
    @synthesize title;
    
    self.title = [[MUZTitleViewController alloc] initWithNibName:nil bundle:nil];
    self.navigationItem.titleView = title.view;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several dataSources I use for one UIViewController. My view controller uses KeyValue
I have an MVC application with a single model and several views (something like
I have a UIViewController, and within that view i have UITableView added in IB
I have a UIViewController that instantiates several UIImageViews on the screen. Is it possible
I have a UIViewController subclass. I add many UILabel by using the [self.view addSubview:]
I have several IBOutlet and use them with IBOutletCollection : @interface IBOutletCollectionViewController : UIViewController
(first UIViewController)I have several UITextfields that will have some number value within them. I
In my application, I have a UIViewController with a subclassed UIView (and several other
In my mainWindow.xib, I have this setup. 1) UINavigationController containing several viewControllers. 2) UIViewController
I have a scroll view with paging control. It loads several pages according to

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.