iPhone xcode - 带有标签栏控制器和多表视图控制器的活动指示器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2673962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:17:25  来源:igfitidea点击:

iPhone xcode - Activity Indicator with tab bar controller and multi table view controllers

iphoneiosxcodeuinavigationbaractivity-indicator

提问by Frames84

I've looked for a tutorial and can't seem to find one for a activity indicator in a table view nav bar. in my mainWindow.xib I have a Tab Bar Controller with 4 Tabs controllers each containing a table view. each load JSON feeds using the framework hosted at Google.

我已经寻找了一个教程,但似乎无法在表格视图导航栏中找到一个活动指示器。在我的 mainWindow.xib 中,我有一个带有 4 个标签控制器的标签栏控制器,每个控制器都包含一个表格视图。每个都使用 Google 托管的框架加载 JSON 提要。

In one of my View Controller I can add an activity indicator to the nav bar by using:

在我的一个视图控制器中,我可以使用以下方法将活动指示器添加到导航栏:

UIActivityIndicatorView *activityIndcator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0,0,20,20)];
[activityIndcator startAnimating];
UIBarButtonItem *activityItem = [[UIBarButtonItem alloc] initWithCustomView:activityIndcator];
self.navigationItem.rightBarButtonItem = activityItem;

however and can turn it off by using:

但是,可以使用以下方法将其关闭:

self.navigationItem.rightBarButtonItem.enabled = FALSE;

But if i place this in my viewDidLoad event it shows all the time. I only want it to show when I select a row in my table view. so I added it at the top of didSelectRowAtIndexPath and the stop line after I load a feed. it shows but takes a second or two and only shows for about half a second.

但是如果我把它放在我的 viewDidLoad 事件中,它就会一直显示。我只希望它在我在表格视图中选择一行时显示。所以我在加载提要后将它添加到 didSelectRowAtIndexPath 和停止线的顶部。它显示但需要一两秒钟,并且只显示大约半秒钟。

is the an event that firers before the didSelectRowAtIndexPath event a type of loading event? if not what is the standard menthord for implementing such functionality?

在 didSelectRowAtIndexPath 事件之前触发的事件是一种加载事件吗?如果不是,实现此类功能的标准方法是什么?

回答by Warrior

Hope this linkhelps You.This explains to display the activity indicator for parsing action of the rss feed.

希望此链接对您有所帮助。这解释了显示用于解析 rss 提要操作的活动指示器。

All the best.

祝一切顺利。

回答by Rayfleck

In .h file

在 .h 文件中

 @property (nonatomic,retain) UIActivityIndicatorView *spinner;

In .m file, @synthesize spinner; // also release in dealloc

在 .m 文件中,@synthesize 微调器;// 也在 dealloc 中释放

In viewDidLoad, do this:

在 viewDidLoad 中,执行以下操作:

UIActivityIndicatorView *activityIndcator = [[UIActivityIndicatorView alloc]    
       initWithFrame:CGRectMake(0,0,20,20)];
self.spinner = activityIndicator;
spinner.hidesWhenStopped = YES; // this is the default, but never hurts to be sure
UIBarButtonItem *activityItem = [[UIBarButtonItem alloc] initWithCustomView:spinner];
self.navigationItem.rightBarButtonItem = activityItem;

In didSelectRowAtIndexPath, do this:

在 didSelectRowAtIndexPath 中,执行以下操作:

 [self.spinner startAnimating];

When feed is done, do this:

进料完成后,请执行以下操作:

 [self.spinner stopAnimating];