Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to have a UIButton action inside a NavigationController's view call the controllers delegate?
    primarykey
    data
    text
    <p>I have my main program with <em>MainAppDelegate.h,MainAppDelegate.m</em>. I have created two custom navigation controllers <em>ANavController, BNavController</em> classes and have created added the controllers in <strong>Interface Builder</strong> and assigned my custom classes to the two controllers inside the <em>MainWindow.xib</em> </p> <p>When the application first loads I make it render the first NavControllers and its view in the <em>didFinishLaunchingWithOptions</em> method:</p> <pre><code>[window addSubView:ANavController.view]; </code></pre> <p>This is works fine and loads the first navigation controllers view. My problem is that within the view on each nav controller, inside the <em>viewDidLoad</em> method I have created a <em>UIBarButtonItem</em> which I add to the right side of the navcontroller. </p> <p>I'm trying to make this button call an action method defined inside my <em>MainAppDelegate.m</em>. </p> <p>For both of my two custom NavController classes I have set the delegate to MainAppDelegate inside <strong>interface builder.</strong> I try to define buttons like so:</p> <pre><code>[flipButton addTarget:self.delegate action:@selector(changeModeAction:) forControlEvents:UIControlEventTouchUpInside]; </code></pre> <p>and obviously then inside <em>MainAppDelegate.m</em> I have defined a method:</p> <pre><code>-(void)changeModeAction:(id)sender </code></pre> <p>This method should flip the ANavigationController currently in the window to he BNavigationController.</p> <p>But it obviously crashes on the <em>addTarget:self.delegate</em>. What's the proper way to do this? Basically I'm trying to add a button to the top right of each NavControl which will fire a FLIP page animation, switching to the other NavController and it's stack.</p> <p>So if you're two levels deep on ANavController and you hit the top right button, it will flip to BNavController and wherever you were last in it's stack. Hitting the button again will flip the page again back to ANavController and you'll still be two levels deep, before you switched to B. Does this make sense? </p> <p>I think my idea implementation needs some work?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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