I have a class that has an extension of UIButton
that shows a UIAlertview
under certain circumstance.
@interface CellButton : UIButton {}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You Lose!"
message:@"Play Again?"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"cancel", nil];
[alert show];
This works fine, but I need to present a view controller when user presses ok.But as you may know you cannot present a view controller with an extension of UIButton
.
So I was wondering if I can put the code below in another viewcontroller and allow it to work with the UIAlert
in Cellbutton
class.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) { // and they clicked OK.
GameController*myNewVC = [[GameController alloc] init];
[self presentModalViewController:myNewVC animated:NO];
}
}