Created
September 19, 2011 09:35
-
-
Save rsaunders100/1226218 to your computer and use it in GitHub Desktop.
(iOS) UIAlert View Example - Has a delegate for Yes/No Taps Will only display popup once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) showConfirmationAlert | |
{ | |
// A quick and dirty popup, displayed only once | |
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"HasSeenPopup"]) | |
{ | |
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Question" | |
message:@"Do you like cats?" | |
delegate:self | |
cancelButtonTitle:@"No" | |
otherButtonTitles:@"Yes",nil]; | |
[alert show]; | |
[alert release]; | |
[[NSUserDefaults standardUserDefaults] setValue:@"YES" forKey:@"HasSeenPopup"]; | |
} | |
} | |
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex | |
{ | |
// 0 = Tapped yes | |
if (buttonIndex == 0) | |
{ | |
// .... | |
} | |
} |
Should replace this by UIAlertController now~
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes is actually buttonIndex of 1