I’m attempting create a spinning reload button, such as the one found in the new Path app.
It’s for a UIWebView, and should behave in the following way:
upon touchupinside, it should reload the webview and spin while it reloads.
while it’s spinning, another touchupinside should stop the reloading of the webview.
upon completion of the reload, it should stop spinning
it should be a subview of UINagivationController
Can a kind individual point me in the right direction or link me to a tutorial on something like this? I’ve searched around and there doesn’t seem to be anything similar. Thanks!
The
UIActivityIndicatorclass will give you the functionality you need. UsestartAnimatingandstopAnimatingalong withhidesWhenStopped. Documentation is here: http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIActivityIndicatorView_Class/Reference/UIActivityIndicatorView.htmlTo use this with your UIWebView, you can place the calls to the UIActivityIndicator in the UIWebViewDelegate methods.
In
webView:shouldStartLoadWithRequest:navigationType:you should return YES, and start the activity indicator. IndidFailLoadanddidFinishLoadyou can then stop the activity indicator.Finally, for your touchUpInside behaviour, you can send the following messages to your
UIWebView,reloadandstopLoading.An alternative would be to call the UIActivityIndicator’s methods at the same time as calling
reloadandstopLoading.