UIActivityIndicatorView not appearing iOS 5

我只是一个虾纸丫 提交于 2019-12-11 04:38:52

问题


I am trying to implement a simple spinner while my app seeks data from the Internet. My data grab is working fine, but it sometimes takes a while, so I'd like to use a UIActivityIndicatorView to let the user know that the app hasn't crashed. But it's currently not working. I've gleaned as much as I can from these forums, and others, but for some reason it's not working. Again, I feel like this solution is probably very simple. Here's what I'm doing:

I declare the spinner as a property in the .h file:

 @property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;

I have also dragged a spinner object onto the viewcontroller using storyboard, and created a connection to the property using CTRL-drag.

The button that triggers the URL request (and consequent loading & parsing of data) actually triggers a segue, so I figure using the

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

function is as good a place as any to get things started. I don't have a specific function attached to the button apart from the prepareforsegue function. (Maybe this is an issue? does it need to have an IBAction associated?...)

Anyway, that function triggers this:

 [self GoAheadAndGetData];

which, in turn, begins like so:

 - (void)GoAheadAndGetData {

[NSThread detachNewThreadSelector:@selector(threadStartAnimating:) toTarget:self withObject:nil];
  ....... etc

So that function looks like this:

 - (void) threadStartAnimating:(id)data 
 {
    [activityIndicator startAnimating];
 }

And finally, at the end of the GoAheadAndGetData function, I have placed the stop animating call, like so:

 [activityIndicator stopAnimating];

Is that clear? Please let me know if anyone needs more info - I have tried to strip it down to basics, so I don't have to post a ton of code here...

Thank you in advance - I'd really appreciate any help I could get. I don't quite know why it's not working at this point.

来源:https://stackoverflow.com/questions/10145045/uiactivityindicatorview-not-appearing-ios-5

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