How can I use two actions for UIButton
click?I have a UIAlertView showing with two button.Play again and exit.Now i want to execute two method in the click event of these buttons.
A view that displays an alert message.
UIAlertView is deprecated. You can now use UIAlertController as explained here.
You can create a UIAlertView like this
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"reset", nil]; [alert show];
To handle AlertView button click, you have to conform to UIAlertViewDelegate
protocol.
@interface YourViewController:UIViewController<UIAlertViewDelegate>{ ....... ....... }
Then implement UIAlertViewDelegate
protocol methods,
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == [alertView cancelButtonIndex]){ //cancel clicked ...do your action }else{ //reset clicked } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With