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

前端 未结 3 1025
眼角桃花
眼角桃花 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 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.

提交回复
热议问题