Reputation: 4033
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
Upvotes: 1
Views: 3659
Reputation: 437592
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:
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:
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.
Upvotes: 2