I want to display activity indicator when user clicks on Tab Bar.
How do I do that?
You will need to conform to the <UITabBarDelegate>
protocol to be informed when a tab is pressed and then you will need to implement
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
This is to give you the hook to be able to now set the activity indicator then:
If you are referring to the indicator in the title bar at the top then the code is
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
This is used to indicate network activity and therefore should not really be used to indicate that your app is loading if it is not using the network. This could lead to people misunderstanding what your app is doing and shutting it down if they do not expect it to connect to the network.
If you are using it to indicate network activity it is normally better to start it at the time when you start using the network and then in later method where you are informed that the network is finished with you hide it again at this point.