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

混江龙づ霸主 提交于 2019-12-02 01:53:27

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.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!