Reputation: 592
I have a segue that I want to be preformed when I push the Manual Entry and Scan Tag buttons on my AlertView.
@implementation triageViewController
- (IBAction)addNew:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Add A New Entry"
message:@"Choose a way to add a new entry."
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Manual Entry", @"Scan Tag", nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex != alertView.firstOtherButtonIndex) {
[self performSegueWithIdentifier:@"manual" sender: self];
}
if (buttonIndex != alertView.cancelButtonIndex) {
[self performSegueWithIdentifier:@"scan" sender: self];
}
}
(I realize this would probably make the cancel button preform a segue right now, but i'm more concerned with making it work)
I have the two segues in my storyboard, going from a UITabViewController to two different UIViewControllers. neither of these are being called, so when I tap them. I tried using both push and modal segues, but neither one was working.
I also tried the if/else statement like so:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[self performSegueWithIdentifier:@"manual" sender: self];
}
if (buttonIndex == 1) {
[self performSegueWithIdentifier:@"scan" sender: self];
}
}
But this is not working either.
Could someone help me figure out what is going wrong? Again in case I was unclear, I want to preform a segue from a UIAlertView pop-up located on a UITabBarController to two separate UIViewControllers. Thanks
Upvotes: 0
Views: 292
Reputation: 300
It looks like your UIAlertView
has a delegate
of nil
so your function is never being called. Set that to self
and then in your view controller's header make sure you're implementing the UIAlertViewDelegate
protocol.
Upvotes: 1