开发者

Activity Indicator IOS usage question

First I would like to thank everyone who attempts to help me with my problem, I am new to iOS development, specifically objective-c, so I apologize if my question is extremely obvious.

I am making an app that loads some new data (parsed from a website but it is NOT a UIWebV开发者_开发知识库iew) into the same current view every time the user changes a selection on the picker view (UIPickerView). The method that inserts this new data into the current view is called -(IBAction) getNewData: (id) sender.

getNewData is called every time the user makes a new selection with the picker. This is how it is called within the picker method and the picker as well as everything else works fine.

- (void)pickerView:(UIPickerView*)pickerView 
      didSelectRow:(NSInteger)row 
       inComponent:(NSInteger)component
{
    NSString *choosen;
    choosen = [currentLottoNames objectAtIndex:row];    
    [self getNewData:choosen];
}

I would like to implement an activity indicator (spinner) for the loading time in-between the time the user makes/changes his selection on the scroller to the time the actual data shows up in the view after the user has made his selection on the scroller. How would I go about implementing this?

Thank you.


To show the user that you are accessing information via apples built in status bar you use

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

If you would like to display like a pop up message you need to declare in the header a

 UIAlertView *load_message;

and then when you would like to show the load_message use

load_message = [[UIAlertView alloc] initWithTitle:@"Loading..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
    [load_message show];
    UIActivityIndicatorView *active = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    active.center = CGPointMake(load_message.bounds.size.width / 2, load_message.bounds.size.height - 40);
    [active startAnimating];
    [load_message addSubview:active];

and that will show a pop up displayed to the user that you are loading something. This is for locking up the screen showing the user that you are getting some information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜