OpenUrl freezes app for over 10 seconds

前端 未结 11 979
孤街浪徒
孤街浪徒 2020-12-13 02:05

I\'m currently developing an App, that needs to open a browser to display a webpage. To do that i use the [UIApplication sharedApplication] openURL method with

11条回答
  •  Happy的楠姐
    2020-12-13 02:29

    If you put the "openURL" action in the viewDidLoad method, then it sure will execute slowly. You can put it in the viewDidAppear method. Or, you can use the GCD in the viewDidLoad method like below:

    dispatch_async(dispatch_get_main_queue(), ^{
        [[UIApplication sharedApplication] openURL:url];
    });
    

提交回复
热议问题