wait_fences: failed to receive reply: 10004003?
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: (MP开发者_JS百科MediaPickerController *)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 https://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
I also noticed that replacing clickedButtonAtIndex: with didDismissWithButtonIndex: when using UIActionSheet or UIAlertView seems to make the error message go away.
精彩评论