Note that there are some explanatory texts on larger screens.

plurals
  1. POCrasher in a custom view as UINavigationControllers navigationItem.titleView
    primarykey
    data
    text
    <p>I have an <code>UIViewController</code> with several subviews in its view property (<code>UISearchbar</code> and several <code>UIButton</code>s). The <code>UIButton</code>s hooked up to typical <code>IBAction</code>s like <code>-(IBAction)buttonPressed:(id)sender</code> for the <code>UIControlEventTouchUpInside</code> state - it doesn't matter if I do it in IB or programmatically.</p> <pre><code>- (void)viewDidLoad { MUZTitleViewController *title = [[MUZTitleViewController alloc] initWithNibName:nil bundle:nil]; self.navigationItem.titleView = title.view; } </code></pre> <p>In my project there's also an <code>UINavigationController</code>. When I set the <code>navigationItem.titleView</code> of the <code>UINavigationBar</code> to the view of my <code>UIViewController</code>s view I get an EXC_BAD_ACCESS exception, as soon as I tap one of the button. I don't know why this is.</p> <p>I uploaded a small sample project to illustrate my problem: <a href="http://cl.ly/A1xU" rel="nofollow">Test010.xcodeproj</a> (it's ARC enabled)</p> <p>More and more I come to the conclusion that it's not a good idea to use the <code>UIViewController</code>s view and assign it to the <code>titleView</code> but I don't see any alternative here.</p> <p><strong>Edit:</strong> Sorry, the sample project commented out the call which causes the exception. I reuploaded the linked project file.</p> <p><strong>Edit^2:</strong> As PengOne pointed out I've skipped the exact error message I got:</p> <pre><code>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' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload