本文介绍了wait_fences:未收到回复:10004003的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用其中的文本字段创建的警报视图。当我通过提交或取消按钮关闭alertview时,我在控制台中收到wait_fences错误。它没有崩溃,或者我没有能够让它崩溃,但我真的想知道发生了什么。

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];

我环顾四周试图弄清问题是什么,有些人提到辞职第一响应者。我添加到 - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex但它没有做任何事情。

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");
}

}

然后我添加了一个if语句来尝试查找字段是否是第一个响应者而我什么都没有。

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?

推荐答案

所以我想我已经弄清楚了。

so i think ive got it figured out.

似乎当我从alertView:didDismissWithButtonIndex调用[field resignFirstResponder]时,firstResponder无法真正辞职,并且在alertView之后键盘将被强制退出一两秒钟被删除了。但是当我从alertView调用[field resignFirstResponder]时:clickedButtonAtIndex它会像它应该的那样重新签名firstResponder。

it seems that when i was calling [field resignFirstResponder] from alertView:didDismissWithButtonIndex, firstResponder wouldnt really resign and the keyboard would be forced out a second or two after the alertView had been removed. but when i call [field resignFirstResponder] from alertView:clickedButtonAtIndex it would resign firstResponder like it is supposed to.

我还遇到了一个问题,因为在取消之前,alertview会向下移动,以弥补键盘不在那里,但为了解决这个问题,我创建了一个单独的功能目的是调用[field resignFirstResponder]并从alertView:clickedButtonAtIndex调用它并将其延迟运行.2秒。

I also ran into a problem were the alertview would move down before being removed, to compensate for the keyboard not being there, but to fix this i created a function thats sole purpose is to call [field resignFirstResponder] and called that from alertView:clickedButtonAtIndex and delayed it being run by .2 seconds.

这篇关于wait_fences:未收到回复:10004003的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 23:56