iOS - 选项卡栏应用程序中的 UIActivityIndicatorView
我只是想寻找一些关于如何实现这一点的提示。我有一个带有 3 个选项卡的选项卡栏应用程序,每个选项卡都会从互联网加载一些数据。我的想法是从委托方法 -didSelectViewController:
获取选定的选项卡项标题,
从那里我将检查选择了哪个选项卡,然后开始旋转 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(...) {
// ...
}
我有吗概念正确吗?
我应该使用一些特定的 UIActivityIndicatorView 如 MBProgressHUD 或 SVProgressHUD 吗? (虽然我不想用额外的代码使我的应用程序复杂化,最重要的是我想理解使用 UIActivityIndicatorView 的概念)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅泰勒的答案:在下载 NSData dataWithContentsOfURL 时实现 UIActivityIndicatorView
我认为它完全满足您的 UIActivityIndicator 需求。
See Tyler's Answer Here: implementing UIActivityIndicatorView while NSData dataWithContentsOfURL is downloading
I think it fits the bill perfectly for your UIActivityIndicator needs.