I have code in which I have array of view in scroll view. In each view I create image view and button. Now i want to set a event on button that is when click on button then activity indicator will appear on view and start animation and when finish upload of next view or image then stop and hide activity indicator. What I will do in code so that it work? How do that? In short i want to display activity indicator on view when click on button and hide when neat view appear.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
make a function and call that on button click, and add this code in your function
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setCenter:CGPointMake(480/2.0, 128.0/2)]; // (mid of screen) I do this because I'm in landscape mode
[yourView addSubview:spinner];
[spinner startAnimating];
[spinner release];
Use this to remove the spinner:
[spinner removeFromSuperview];
here spinner is, UIActivityIndicatorView *spinner;
(I've declared in .h of ma code)