views:

35

answers:

2

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?

A: 

Did you try removing textfield like:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {

[[alertView.subviews objectAtIndex:0] removeFromSuperview];


}
Deniz Mert Edincik
thanks for the quick response. i put that in and now im getting an error saying 'Void value not ignored as it ought to be'. I have a feeling this can help answer the problem but i dont really understand what it means or where i need to start looking now. i tried searching around but it seems to come up for a variety of problems. thanks.
Jeff B
sorry my bad, edited my answer.
Deniz Mert Edincik
putting that in just gives me the same error(wait_fences...). is there any way i can find what is the first responder? i thought i was making the textfield the first responder but it doesnt seem to be.
Jeff B