开发者

iphone : How to display Activity Indicator on clicking Tab Bar?

I want to display activity indicator when user clicks on Tab Bar.

How do I开发者_StackOverflow 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.


To show:

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

To hide:

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

Apple Docs: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html


You should override this method:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item;

You then could add this:

[spinner startAnimating];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜