【问题标题】:Calling method presentViewController from the UIViewController in an asynchronous way以异步方式从 UIViewController 调用方法 presentViewController
【发布时间】:2012-11-30 16:58:41
【问题描述】:

有什么机制可以异步调用presentViewController方法吗?

UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
imagePicker.delegate = self;
imagePicker.sourceType  = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = @[(NSString *) kUTTypeImage];
imagePicker.allowsEditing = NO;
[self.viewController presentViewController:imagePicker animated:YES completion:nil];

【问题讨论】:

  • 为什么要以异步方式调用它?你想达到什么目的?
  • 我认为你可以安排它在下一个运行循环中执行。有什么特别的原因吗?
  • 我不知道如何解释,所以也许它没有任何意义。无论如何,我将以标准方式(同步)使用它。

标签: ios uiviewcontroller uiimagepickercontroller


【解决方案1】:

UI方法必须在主线程上运行,所以不能异步调用

【讨论】:

    【解决方案2】:

    不,这是设计同步的。但是您可能会启动另一个线程,并在那里进行同步调用。但我不会那样做。

    【讨论】:

    • Alex,创建一个新线程是什么意思? UI 对象需要在主线程中执行。
    猜你喜欢
    • 1970-01-01
    • 2019-05-26
    • 1970-01-01
    • 2014-03-25
    • 2017-09-23
    • 1970-01-01
    • 2017-03-06
    • 2014-09-13
    相关资源
    最近更新 更多