wait_fences:未能收到回复: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 = @"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]; }
通常:
-
viewWillAppear
只能在viewDidAppear
做任何animation。 只准备您的数据,网点等在viewWillAppear
。 -
另外一个很常见的情况是,当你有一个animation对话框(像你的
MPMediaPickerController
),导致另一个animation视图出现(像自定义模态UIViewController
)等,在这种情况下,你需要“推迟”的演示文稿第二个viewcontroller像这样:[self performSelector:@selector(showMyOtherViewController) withObject:nil afterDelay:0.1];
也检查出这个答案https://stackoverflow.com/7194182 。
编辑
“debugging”冲突animation的一个好方法是简单地将animation设置为“ NO
,而不是在代码中
[self presentModalViewController:mediaPicker animated:YES]; [self dismissModalViewControllerAnimated:YES];
简单地做:
[self presentModalViewController:mediaPicker animated:NO]; [self dismissModalViewControllerAnimated:NO];
并检查wait_fences
错误是否消失,并获得正确的行为(但没有animation)。 如果是这种情况,你需要一些performSelector:withObject:afterDelay:
-magic。
编辑:请注意,您可以在iOS 5.0中执行以下操作:
[self dismissViewControllerAnimated:YES completion:^{ [self presentViewController:anotherViewController animated:YES completion:NULL] }
这意味着首先,当前呈现的视图控制器(例如ModalViewController)被解散,当animation完成时,您可以调用另一个块。 在这种情况下显示另一个UIViewController
我还注意到,replaceclickedButtonAtIndex:与didDismissWithButtonIndex:当使用UIActionSheet或UIAlertView似乎使错误消息消失。