iPhone:如何在单击选项卡栏时显示活动指示器? [英] iphone : How to display Activity Indicator on clicking Tab Bar?

查看:71
本文介绍了iPhone:如何在单击选项卡栏时显示活动指示器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户单击选项卡栏时显示活动指示器。

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

我该怎么做?

推荐答案

您需要符合< UITabBarDelegate> 协议,以便在按下某个选项卡时得到通知,然后您需要实现

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.

这篇关于iPhone:如何在单击选项卡栏时显示活动指示器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆