search

Home  >  Q&A  >  body text

objective-c - dismissViewControllerAnimated execution has delay

Clicked the tableView in

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

Execute

[self dismissViewControllerAnimated:YES completion:nil];

The current interface will not close immediately and there will be a 3-4s delay. If you click anywhere on the current interface again, it will close immediately.

This problem does not occur when using Button to execute the above code to close it.

天蓬老师天蓬老师2807 days ago751

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-05-02 09:29:55

    I also encountered the exact same problem. It can be solved by adding the following

    dispatch_async(dispatch_get_main_queue(), ^{
            [self dismissViewControllerAnimated:NO completion:nil];
        });

    I have also printed that the threads are all main threads, but I don’t understand why such a problem occurs
    <NSThread: 0x17007a040>{number = 1, name = main}

    reply
    0
  • Cancelreply