How start animation of activity indicator when click on button?

孤街浪徒 提交于 2019-12-14 03:09:51

问题


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)



来源:https://stackoverflow.com/questions/6841385/how-start-animation-of-activity-indicator-when-click-on-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!