iphone:如何在单击选项卡栏时显示活动指示器?
我想在用户单击选项卡栏时显示活动指示器。
我该怎么做?
I want to display activity indicator when user clicks on Tab Bar.
How do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要遵守
协议,以便在按下选项卡时收到通知,然后您需要实现此功能,以便为您提供现在能够设置活动指示器的钩子然后:
如果您指的是顶部标题栏中的指示器,则代码是。
此代码用于指示网络活动,因此不应真正用于指示您的应用程序在不使用网络的情况下正在加载。这可能会导致人们误解您的应用程序正在做什么,如果他们不希望它连接到网络,则会将其关闭。
如果您使用它来指示网络活动,通常最好在开始使用网络时启动它,然后在稍后的方法中,当您被告知网络已完成时,您此时再次隐藏它。
You will need to conform to the
<UITabBarDelegate>
protocol to be informed when a tab is pressed and then you will need to implementThis 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
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.
显示:
隐藏:
Apple 文档: http ://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html
To show:
To hide:
Apple Docs: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html
您应该重写此方法:
然后您可以添加以下内容:
You should override this method:
You then could add this: