0

I'm just fishing for some hints on how to implement this. I have a Tab Bar application with 3 tabs and each tab loads some data from the internet. My idea is to get the selected tab item title from the delegate method -didSelectViewController:

From there I will check what tab is selected like so and start spinning the UIActivityIndicatorView:

if([viewController.tabBarItem.title isEqualToString:@"Tab 2"]) {

    // Start spinning the UIActivityIndicatorView
    [spinner startAnimation];

    // Download the appropriate data for Tab 2
    NSArray *data = [MyClass getData];

    // Stop spinning the UIActivityIndicatorView
    [spinner stopAnimation];

    // This is the tricky part (at least I think), I need to pass this data on to the ViewController that is setup for Tab 2, how can I do that?

    } else if(...) {
    // ...
}

Have I gotten the concept correct?

Should I use some specific UIActivityIndicatorView like MBProgressHUD or SVProgressHUD? (though I don't want to complicate my application with extra code, and most importantly I want to understand the concept of using the UIActivityIndicatorView)

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
  • Are you going to be using a webView in any way? I don't know if the way you are going to handle switching views is very efficient. Why not have the data downloaded in ViewDidLoad? – Sum Jul 12 '11 at 19:50
  • No, no webview. Well it's just how I thought would be a good way to implement it. – Peter Warbo Jul 12 '11 at 20:44

1 Answers1

0

See Tyler's Answer Here: implementing UIActivityIndicatorView while NSData dataWithContentsOfURL is downloading

I think it fits the bill perfectly for your UIActivityIndicator needs.

Community
  • 1
  • 1
Sum
  • 4,369
  • 1
  • 22
  • 38