dismissModalViewControllerAnimated非原子的? [英] dismissModalViewControllerAnimated nonatomic?

查看:70
本文介绍了dismissModalViewControllerAnimated非原子的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,我有一个奇怪的计时问题.我打开uiimagepicker作为模式视图.当用户选择图像或我要拍摄图像时,将其保存到变量中,然后以模式视图的形式打开电子邮件界面.

I have a weird timing issue, it seems. I open a uiimagepicker as a modal view. When the user picks an image or I want to take the image, save it to a variable, then open an email interface as a modalview.

我的问题是我正在图像选择器上调用dismissModalViewController,然后为我的电子邮件接口调用presentmodalviewcontroller,但是图像选择器没有及时消失以显示电子邮件视图.有没有办法等待"该行代码完成?

My problem is that I am calling dismissModalViewController on the imagepicker, then calling presentmodalviewcontroller for my email interface, but the imagepicker isn't going away in time for the email view to be presented. Is there a way to 'wait' for that line of code to complete?

(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
  if( [[info objectForKey:UIImagePickerControllerMediaType] isEqualToString:@"public.image"] ){
    [self dismissModalViewControllerAnimated:YES];
    imageFromCamera = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];

  MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
  mailView.mailComposeDelegate = self;
  [self presentModalViewController:mailView animated:YES];
  [mailView release];

}   
}

我很确定我设计了错误的东西,但是如果可以的话,请帮帮我.

I'm pretty sure I've designed something wrong, but help me out if you can.

推荐答案

您可以使用performSelector:withObject:withDelay:等待给定时间过去(创建另一个具有代码待稍后执行的方法.

You can use performSelector:withObject:withDelay: to wait for a given time to pass (create another method that has the code to do later.

但是,这可能会引入许多细微的计时错误,因此我建议仅在最极端的情况下使用它.

However, this can introduce lots of subtle timing bugs, so I'd suggest using it for only the most extreme of cases.

我认为您可能可以通过viewDidAppear:进行某些操作,以查找您在didFinishPicking…中设置的标志,该标志表示您正在等待imagePicker的动画结束.既然是didAppear,那么动画应该在那时完成.

I think you could probably do something with viewDidAppear: look for a flag that you've set in didFinishPicking… indicating that you're waiting for the imagePicker's animation to end. Since it's didAppear, the animations should be done by then.

这篇关于dismissModalViewControllerAnimated非原子的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆