我收到这个神秘的消息:wait_fences:未能收到回复:10004003 我用google搜索,人们认为它与未正确解雇UITextField或Alert有关。我的应用程序中有一个文本字段,我向您保证我使用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 = @"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];
}
答案 0 :(得分:4)
一般而言:
您不应仅在viewWillAppear
viewDidAppear
中执行任何动画。仅在viewWillAppear
。
wait_fences
可能出现的一个非常常见的情况是,当您有一个动画对话框(如MPMediaPickerController
)导致另一个动画视图出现时(如自定义模式{{1在这种情况下,您需要“推迟”第二个视图控制器的演示文稿,如下所示:
UIViewController
同时查看此答案https://stackoverflow.com/7194182。
修改强>
“调试”冲突动画的好方法是简单地将动画设置为 [self performSelector:@selector(showMyOtherViewController)
withObject:nil
afterDelay:0.1];
,因此在代码中而不是
NO
简单地说:
[self presentModalViewController:mediaPicker animated:YES];
[self dismissModalViewControllerAnimated:YES];
并检查 [self presentModalViewController:mediaPicker animated:NO];
[self dismissModalViewControllerAnimated:NO];
错误是否消失并且是否实现了正确的行为(但没有动画)。如果是这种情况,您需要一些wait_fences
- 魔术。
修改:请注意,您可以在iOS 5.0中执行以下操作:
performSelector:withObject:afterDelay:
这意味着首先,当前呈现的视图控制器(例如ModalViewController)被解除,并且当动画完成时,您可以调用另一个块。在这种情况下,显示另一个[self dismissViewControllerAnimated:YES completion:^{
[self presentViewController:anotherViewController animated:YES completion:NULL]
}
答案 1 :(得分:0)
我还注意到使用didDismissWithButtonIndex替换clickedButtonAtIndex:当使用UIActionSheet或UIAlertView时,似乎会使错误消息消失。