How do I use a progress indicator?
// Implementviewdidload to do additional setup after loading the view, typically from anib.
-(Void) viewdidload {
// Load the spinner here
Note that the webview setdelegate: Self
Statement. Only the following four web views can be processed.
Heavy Load Process
Spinner = [[uiactivityindicatorview alloc] initwithframe: cgrectmake (0, 0, 50, 50)];
[Spinnersetcenter: cgpointmake (350,350)]; // I do this because I'm in Landscape mode
[Spinnersetactivityindicatorviewstyle: uiactivityindicatorviewstylegray];
[Self. viewaddsubview: spinner]; // spinner is not visible until started
[Webviewsetdelegate: Self];
[Superviewdidload];
}
# Pragma mark-
# Pragma mark Web View Lifecycle
-(Void) webviewdidstartload :( uiwebview *) webview
{
[Spinnerstartanimating];
// Opaqueview. Hidden = no;
}
-(Void) webviewdidfinishload :( uiwebview *) webview
{
[Spinnerstopanimating];
// [Spinner release];
* ** If you use this sentence here, an error may occur and the screen is stopped, especially when different content is repeatedly refreshed on the same screen. It also indicates that in some cases, release is enabled in advance.
Some variables may cause problems.
// Opaqueview. Hidden = yes;
}
-(Bool) webview :( uiwebview *) webviewshouldstartloadwithrequest :( nsurlrequest *) requestnavigationtype :( uiwebviewnavigationtype) navigationtype
{
// [Spinnerstartanimating];
Returnyes;
}
-(Void) webview :( uiwebview *) webviewdidfailloadwitherror :( nserror *) Error
{
[Spinnerstopanimating];
}