objective-c “wait_fences:未能收到回复:10004003”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1371346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"wait_fences: failed to receive reply: 10004003"?
提问by Michael
I get this cryptic error the first time (and only the first time) my view is loaded due to the following line of code:
由于以下代码行,我第一次(也是第一次)我的视图被加载时出现这个神秘错误:
- (void)viewWillAppear:(BOOL)animated
{
[textField becomeFirstResponder];
}
There is a noticeable (~3 –?4 second, even on the simulator) delay due to this that makes my app feel unresponsive. Does anyone know how to fix this? I can't find any documentation on it on Apple's site, or any solutions here or on Google.
有一个明显的(~3 –?4 秒,即使在模拟器上)延迟,因为这让我的应用程序感觉没有响应。有谁知道如何解决这一问题?我在 Apple 的网站上找不到任何关于它的文档,或者在这里或谷歌上找不到任何解决方案。
Strangely, the opposite situation happens if I put the line in -viewDidAppear:instead of -viewWillAppear:; that is, instead of printing the error only the first time the keyboard is shown and never again, the error is notprinted the first time but every time after. This is causing a major headache for me.
奇怪的是,如果我把这条线放在-viewDidAppear:而不是-viewWillAppear:; 那就是,不是打印错误仅在第一次键盘显示永不再被错误不打印的第一次,但之后每次。这让我很头疼。
回答by Rob Napier
Override -viewDidAppear:, not -viewWillAppear, and make sure to call [super viewDidAppear:]. You should not perform animations when you are not on screen ("will appear"). And the -viewDidAppear:docs explain that you must call superbecause they have their own things to do.
覆盖-viewDidAppear:,不-viewWillAppear,并确保调用[super viewDidAppear:]。当您不在屏幕上时(“将出现”),您不应执行动画。和-viewDidAppear:文档说明,你必须调用super,因为他们有自己的事情要做。
回答by Corey Floyd
I was getting a similar error when quickly:
我很快就收到了类似的错误:
- Dismissing a modal view
- Updating the main view
- Presenting a new modal view
- 关闭模态视图
- 更新主视图
- 呈现新的模态视图
I noticed I was only getting it in the simulator and not on the device. Additionally, I was getting caught in an infinite loop.
我注意到我只在模拟器中而不是在设备上得到它。此外,我陷入了无限循环。
My solution was to delay the presenting of the new modal view. It seems that quickly updating the view hierarchy caused some sot of race condition in Apple's code.
我的解决方案是延迟新模式视图的呈现。似乎快速更新视图层次结构在 Apple 的代码中导致了一些竞争条件。
With that in mind, try this:
考虑到这一点,试试这个:
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[textField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.1];
}
You may be having issues presenting the keyboard for a UITextField that ins't yet on screen. This may be causing problems similar to mine.
您可能在为尚未显示在屏幕上的 UITextField 显示键盘时遇到问题。这可能会导致与我类似的问题。
Also, you pause giving the hierarchy time to update before presenting the keyboard, just in case.
此外,您可以在显示键盘之前暂停给层次结构更新时间,以防万一。
Hope this helps.
希望这可以帮助。
回答by diachedelic
Check you are only interacting with the UI on the main thread. I got wait_fences: failed to receive reply: 10004003while I was sitting there waiting for a UIAlertView to show for about 5 seconds because the relevant code was executed on a background thread. You can make sure by putting your code in block and sending it to the main thread:
检查您是否仅与主线程上的 UI 交互。我wait_fences: failed to receive reply: 10004003坐在那里等待 UIAlertView 显示大约 5 秒钟,因为相关代码是在后台线程上执行的。您可以通过将代码放入块并将其发送到主线程来确保:
dispatch_async(dispatch_get_main_queue(), ^{
if (!success) {
// Inform user that import failed
UIAlertView * importFailedAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ErrorTitle5", @"Import failed")
message:NSLocalizedString(@"Error5", @"Something went wrong")
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil];
[importFailedAlert show];
}
});
回答by warehouselabs
After trying everything I could find on Google and none of it working, this is what solved the problem for me. The key is that I'm doing this stuff in the willDismissWithButtonIndex delegate method. Before I was doing it elsewhere.
在尝试了我在谷歌上能找到的所有东西但没有一个工作之后,这就是为我解决问题的方法。关键是我在 willDismissWithButtonIndex 委托方法中做这些事情。在我在别处做之前。
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
[myTextField resignFirstResponder];
[myTextField removeFromSuperview];
[myTextField release];
}
回答by rlcoder
If you have the following line in viewDidLoad, it can cause this message. Comment the following line.
如果 viewDidLoad 中有以下行,则可能会导致此消息。注释以下行。
[[UIApplication sharedApplication] setStatusBarHidden:YES]; //This line should be commented
(You can disable the status bar from the application plist file instead).
(您可以改为从应用程序 plist 文件中禁用状态栏)。
回答by nverinaud
After few tests the big rule is: "Do not perform animation before animated dismissal or animated show.".
经过几次测试后,大规则是:“不要在动画解散或动画放映之前执行动画。”。
For example:
例如:
- do not call
-dismissModalViewControllerAnimated:YESafter the delegation callback of anUIAlertView -alertView:willDismissWithButtonIndex:(wait the fade out of the alert view before doing this using the-alertView:didDismissWithButtonIndex:callback) - do not try to show the keyboard (
becomeFirstResponder) before your view controller is on screen.
- 不要
-dismissModalViewControllerAnimated:YES在委托回调之后调用(在使用回调执行此操作之前等待警报视图淡出)UIAlertView -alertView:willDismissWithButtonIndex:-alertView:didDismissWithButtonIndex: becomeFirstResponder在视图控制器出现在屏幕上之前,不要尝试显示键盘 ( )。
Bad things may happen.
可能会发生不好的事情。
Hope it will be useful ;-)
希望它会有用;-)
回答by ma11hew28
This worked for me to get the keyboard to show itself immediately, without animation or delay.
这对我有用,可以让键盘立即显示出来,没有动画或延迟。
Let textFieldbe an instance variable of MyViewController(a subclass of UIViewController).
让textField成为MyViewController(的子类UIViewController)的实例变量。
Call [textField becomeFirstResponder]in initWithNibName:bundle:(for a subclass of UIViewController) or initWithStyle:(for a subclass of UITableViewController), not in viewDidLoad. E.g.:
通话[textField becomeFirstResponder]中initWithNibName:bundle:(用于一个子类UIViewController)或initWithStyle:(对于的子类UITableViewController),而不是在viewDidLoad。例如:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[textField becomeFirstResponder];
}
return self;
}
Or, call it just after initializing but before pushing the UIViewController. E.g.:
或者,在初始化之后但在推送UIViewController. 例如:
MyViewController *viewController = [[MyViewController alloc] init];
[viewController.textField becomeFirstResponder];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
回答by Gani
You have done [textfield becomeFirstResponder];
你已经完成了 [textfield becomeFirstResponder];
And after you get the value from textfield in your code, do [textfield resignFirstResponder];. That will help you, I think.
在您从代码中的文本字段获取值后,执行[textfield resignFirstResponder];. 那会帮助你,我想。
回答by Matt Gallagher
If you're running the current iPhone Simulator 4.0, this error message appears frequently when rotating the screen (or when animating after rotating the screen) accompanied by 1-2 second lag in the animations.
如果您正在运行当前的 iPhone Simulator 4.0,则在旋转屏幕时(或在旋转屏幕后制作动画时)经常出现此错误消息,并伴有 1-2 秒的动画延迟。
It is a bug in this version of the Simulator and should be fixed soon.
这是此版本模拟器中的错误,应尽快修复。
回答by Wagh
override viewDidappear, not viewWillAppear:
覆盖viewDidappear,而不是viewWillAppear:
-(void) viewDidAppear:(BOOL) animated
{
[super viewDidAppear:animated];
[myTextField becomeFirstResponder];
}

