wait_fences:未能接收回复:10004003? [英] wait_fences: failed to receive reply: 10004003?
问题描述
我得到这个神秘的消息:wait_fences:未能接收回复:10004003
我有google了,人们认为它有关的事情没有正确地关闭UITextField或警报。我有一个文本字段在我的应用程序,我保证你使用resignFirstResponder等正确释放它...
当我从一个子视图打开一个MPMusicPickerController,我得到这个消息,这有什么区别。我真的需要得到这个固定的,因为它是搞砸我的整个应用程序!
谢谢,
布拉德
Edit1:
- (IBAction)openMediaPicker:(id)sender {
[[UIApplication sharedApplication] setStatusBarHidden :YES withAnimation:UIStatusBarAnimationFade];
MPMediaPickerController * mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAny];
mediaPicker.delegate = self;
mediaPicker.allowsPickingMultipleItems = YES;
mediaPicker.prompt = @选择要播放的歌曲;
[self presentModalViewController:mediaPicker animated:YES];
[mediaPicker release];
}
//媒体选择器委托方法
- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
AppAppDelegate * appDelegate =(AppAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.tr2 stop];
[playstopButton setHidden:NO];
[playstopButton setImage:[UIImage imageNamed:@Stop-Music-Button.png] forState:UIControlStateNormal];
//我们需要关闭选择器
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
//将所选项目分配给音乐播放器并开始播放。
[self.musicPlayer stop];
[self.musicPlayer setQueueWithItemCollection:mediaItemCollection];
[self.musicPlayer play];
}
- (void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker {
//用户没有选择任何东西
//我们需要关闭选择器
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
-
您不应在
中执行任何动画viewWillAppear
viewDidAppear 。只在viewWillAppear
中准备您的数据,插座等。 -
c $ c> wait_fences 可能出现的是当你有一个动画对话框(像你的
MPMediaPickerController
)导致另一个动画视图出现modalUIViewController
)等,在这种情况下,你需要推迟第二个视图控制器的呈现如下:[self performSelector:@selector(showMyOtherViewController)
withObject:nil
afterDelay:0.1];
http://stackoverflow.com/7194182\">http://stackoverflow.com/7194182 。
编辑 / p>
一个调试冲突动画的好方法是简单地将动画设置为 NO
[self presentModalViewController:mediaPicker animated:YES];
[self dismissModalViewControllerAnimated:YES];
只需执行:
[self presentModalViewController:mediaPicker animated:NO];
[self dismissModalViewControllerAnimated:NO];
并检查 wait_fences
错误是否消失并且实现了正确的行为(但没有动画)。如果是这种情况,你需要一些 performSelector:withObject:afterDelay:
-magic。
编辑:请注意,您可以在iOS 5.0中执行以下操作:
[self dismissViewControllerAnimated:YES completed:^ {
[self presentViewController:anotherViewController animated:YES completed:NULL]
}
这意味着首先,当前呈现的视图控制器(例如ModalViewController)被关闭,当动画完成时,你可以调用另一个块。在这种情况下显示另一个 UIViewController
I am getting this cryptic message: wait_fences: failed to receive reply: 10004003 I have googled and people think it has something to do with not properly dismissing a UITextField or Alert. I have one textfield in my app and I assure you I release it properly using resignFirstResponder, etc... I get this message when I am opening a MPMusicPickerController from a subview, does that make any difference. I really need to get this fixed because it is messing up my whole app!
Thanks, Brad
Edit1:
- (IBAction)openMediaPicker:(id)sender {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAny];
mediaPicker.delegate = self;
mediaPicker.allowsPickingMultipleItems = YES;
mediaPicker.prompt = @"Select songs to play";
[self presentModalViewController:mediaPicker animated:YES];
[mediaPicker release];
}
// Media picker delegate methods
- (void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
AppAppDelegate *appDelegate = (AppAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.tr2 stop];
[playstopButton setHidden:NO];
[playstopButton setImage:[UIImage imageNamed:@"Stop-Music-Button.png"] forState:UIControlStateNormal];
// We need to dismiss the picker
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
// Assign the selected item(s) to the music player and start playback.
[self.musicPlayer stop];
[self.musicPlayer setQueueWithItemCollection:mediaItemCollection];
[self.musicPlayer play];
}
- (void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker {
// User did not select anything
// We need to dismiss the picker
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
Generally:
You should not do any animations in
viewWillAppear
only inviewDidAppear
. Only prepare your data, outlets etc. inviewWillAppear
.Also a very common case where
wait_fences
might arise is when you have an animated dialog (Like yourMPMediaPickerController
) that causes another animated view to appear (Like a custom modalUIViewController
) or the like, in which case you need to "postpone" the presentation of the second viewcontroller like this:[self performSelector:@selector(showMyOtherViewController) withObject:nil afterDelay:0.1];
Also check out this answer http://stackoverflow.com/7194182.
Edit
A good way to "debug" conflicting animations is to simply set the animation to NO
so in your code instead of
[self presentModalViewController:mediaPicker animated:YES];
[self dismissModalViewControllerAnimated:YES];
Simply do:
[self presentModalViewController:mediaPicker animated:NO];
[self dismissModalViewControllerAnimated:NO];
and check if the wait_fences
error goes away and the correct behaviour (but without animation) is achieved. If this is the case you need some of the performSelector:withObject:afterDelay:
-magic.
Edit: Please note that you can do the following in iOS 5.0:
[self dismissViewControllerAnimated:YES completion:^{
[self presentViewController:anotherViewController animated:YES completion:NULL]
}
That means that first, the currently presented View Controller (e.g. a ModalViewController) is dismissed and when the animation is finished you can invoke another block. In this case show another UIViewController
这篇关于wait_fences:未能接收回复:10004003?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!