I’m currently working in Xcode on an iOS app…
I’ve set up a UIAlertView (with a question as the message ) to pop up with a text field to retrieve a response.
The desired functionality is that upon entering an incorrect value into the text field, the UIAlert would loop… Until the correct response is entered. At this point, the UIAlert would be dismissed.
Heres what I have so far…
- (void)application:(UIApplication *)application
didReceiveLocalNotification:(UILocalNotification *)notification {
NSString* correctAnswer = @"2";
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Alarm"
message:@"1 + 1 ="
delegate:self
cancelButtonTitle: nil
otherButtonTitles:@"Continue", nil ];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField* answerField = [alert textFieldAtIndex:0];
answerField.keyboardType = UIKeyboardTypeNumberPad;
answerField.placeholder = @"answer";
[alert show];
// I feel like this would work, but I know it doesn't...
NSString *answerFieldString = answerField.text;
if ([answerFieldString isEqualToString: correctAnswer ])
{
[alert dismissWithClickedButtonIndex:-1 animated:YES];
}
}
I’ve done extensive google searching and can’t come up with a solution… Any responses would be much appreciated!
try this…