1

I currently have a button within an app that I am working on, and when I press the button it seems to not call the method when it is pressed. I thought added all the proper code, and wired everything up correctly, but that doesn't seem to be the case.

ViewControllerRootHome.h

@property (weak, nonatomic) IBOutlet UIButton *btndev;

- (IBAction)showDev:(id)sender;

ViewControllerRootHome.m

@synthesize btndev = _btndev;

- (IBAction)showDev:(id)sender {

    NSLog(@"dev button pressed");
    //dev button pressed
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    ViewControllerDev *dev = (ViewControllerDev *) [storyboard instantiateViewControllerWithIdentifier:@"dev"];
    [self presentModalViewController:dev animated:YES];
    NSLog(@"dev button press End");
}

The execution is not even reaching the firs log statement in the method.

Things are wired up as such,

On a side note the button that reads "Logs" seems to be loading the scene fine, but for whatever reason "dev" button does not want to call the method / load the scene.

Ohh the source code for everything can be found here, https://github.com/ipatch/KegCop

wiring

ipatch
  • 3,933
  • 8
  • 60
  • 99
  • 1
    Did you try to clean your projet (menu "Product" -> "Clean") and even delete the application from your iPhone Simulator (or Device, if you test on your actual device), before recompiling it and reinstalling it on the Simulator (or Device)? It may simply be Xcode messing up and an old XIB not being properly recompiled? Try to move your "dev" button at another position or change its title in your XIB/Storyboard and check that the change was taken into account when you run to be sure you work on the expected XIB/Storyboard file and that it's updated. – AliSoftware Apr 09 '13 at 23:21

1 Answers1

2

That button works fine, so if you're having problem, I'd refer you to AliSoftware's comment about making sure to clean your build. But if you look to the left of the method name, showDev, you'll see a solid bullet when the IBOutlet is hooked up correctly:

enter image description here

If you compare that to another method, this one, saveMasterEmail is not currently hooked up correctly, evidenced by the empty circle to the left of the method:

enter image description here

Unrelated, your code:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ViewControllerDev *dev = (ViewControllerDev *) [storyboard instantiateViewControllerWithIdentifier:@"dev"];
[self presentModalViewController:dev animated:YES];

could be simplified to:

UIViewController *dev = [self.storyboard instantiateViewControllerWithIdentifier:@"dev"];
[self presentModalViewController:dev animated:YES];

Or, even easier, define a segue for that button and you don't need to do anything with code.

Finally, I'd make sure you avoid circular references between your scenes. You shouldn't be doing a modal segue (or presentViewController or presentModalViewController) from A to B and then again from B to A. If you do a modal segue from A to B, you should call dismissViewControllerAnimated to return back to A. Otherwise, you'll have two instances of A floating around.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • first off, I really appreciate the thorough response, secondly I deleted the "dev" button in the storyboard file. Then I did a "Product" -> "Clean". After that I click the "Run" button, but the button is still showing in the scene even after I removed it, so for whatever reason, my changes are not being written to the storyboard file or something like that :-/ Thanks again for the thorough response Rob. – ipatch Apr 10 '13 at 18:23
  • 1
    following the suggestions in this SO thread,http://stackoverflow.com/questions/692064/cleaning-up-the-iphone-simulator i removed everything from the simulator and that seems to be updating the UI now *keeps fingers crossed* – ipatch Apr 10 '13 at 19:12