Hello. I have an alertview that is being created with a textfield inside of it. when i close the alertview via a submit or cancel button, i am getting the wait_fences error in the console. it doesnt crash, or i havent been able to make it crash but id really like to figure out what is going on.
alert = [[UIAlertView alloc]
initWithTitle:@"Lookup"
message:@"\n\n\n"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Submit", nil];
label = [[UILabel alloc] initWithFrame:CGRectMake(12, 40, 260, 25)];
label.font = [UIFont systemFontOfSize:16];
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
label.shadowColor = [UIColor blackColor];
label.shadowOffset = CGSizeMake(0, -1);
label.textAlignment = UITextAlignmentCenter;
label.text = @"Enter 10-Digit ISBN Number";
[alert addSubview:label];
field = [[UITextField alloc] initWithFrame:CGRectMake(16, 83, 252, 25)];
field.font = [UIFont systemFontOfSize:18];
field.backgroundColor = [UIColor whiteColor];
field.keyboardAppearance = UIKeyboardAppearanceAlert;
field.keyboardType = UIKeyboardTypeNumberPad;
field.borderStyle = UITextBorderStyleBezel;
field.delegate = self;
[field becomeFirstResponder];
[alert addSubview:field];
[alert show];
I looked around online to try and figure out what the problem was and some people had mentioned resigningFirst responder. I added that to - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex but it didnt do anything.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
[field resignFirstResponder]
if (buttonIndex == 1) {
NSLog(@"Submit");
} else {
NSLog(@"Cancel");
}
}
I then added an if statement to try and find out if field was the first responder and i got nothing.
if([field isFirstResponder]) {
NSLog(@"field isFirstResponder");
}
does anyone have any suggestions of what i could have done wrong?