UIAlertView starts to show, screen dims, but it doesn't pop up until it's too late!

前端 未结 3 1026
眼角桃花
眼角桃花 2021-01-23 01:19

I have a button which when pressed makes calls that load information from a series of URLs (about 5 seconds loading time). Right before actually making those calls I want to add

相关标签:
3条回答
  • 2021-01-23 01:52

    If you have a bunch of operations to perform, in addition to performSelectorInBackground: like cescofry wrote, you can use NSOperation and NSOperationQueue.

    0 讨论(0)
  • 2021-01-23 02:03

    when you try to retrieve data from the internet (I guess you are using something like [NSString stringWithContentsOfURL: ...]) the main thread is waiting for those data and for this reason the application cannot redraw the interface. You can try to use:

    [mySourceData performSelectorInBackground:@selector(loadData) withObject:nil];
    

    Be careful if you are using coredata to lock the NSManagedObjectContext before doing any operation on it and unlock it when you finish.

    0 讨论(0)
  • 2021-01-23 02:03

    You probably don't want an UIAlertView for this anyway. Take a look at MBProgressHUD on GitHub.

    0 讨论(0)
提交回复
热议问题