The first method: using UIView and Uiactivityindicatorview
Copy Code code as follows:
Create UIWebView
WebView = [[UIWebView alloc] Initwithframe:cgrectmake (0, 44, 320, 400)];
[WebView Setuserinteractionenabled:no];
[WebView Setbackgroundcolor:[uicolor Clearcolor]];
[WebView setdelegate:self];
[WebView setopaque:no];//makes web pages transparent
NSString *path = @ "http://www.baidu.com";
Nsurl *url = [Nsurl Urlwithstring:path];
[WebView Loadrequest:[nsurlrequest Requestwithurl:url]];
Create Uiactivityindicatorview Background Translucent view
UIView *view = [[UIView alloc] Initwithframe:cgrectmake (0, 0, 320, 480)];
[View settag:103];
[View Setbackgroundcolor:[uicolor Blackcolor]];
[View setalpha:0.8];
[Self.view Addsubview:view];
Activityindicator = [[Uiactivityindicatorview alloc] Initwithframe:cgrectmake (0.0f, 0.0f, 32.0f, 32.0f)];
[Activityindicator SetCenter:view.center];
[Activityindicator Setactivityindicatorviewstyle:uiactivityindicatorviewstylewhite];
[View Addsubview:activityindicator];
[Self.view Addsubview:webview];
[View release];
[WebView release];
Start Loading Data
-(void) Webviewdidstartload: (UIWebView *) WebView {
[Activityindicator startanimating];
}
Data load Complete
-(void) Webviewdidfinishload: (UIWebView *) WebView {
[Activityindicator stopanimating];
UIView *view = (UIView *) [Self.view viewwithtag:103];
[View Removefromsuperview];
}
The second method: using Uialertview and Uiactivityindicatorview
Copy Code code as follows:
Load a Web page animation
-(void) Webviewdidstartload: (UIWebView *) webview{
if (Myalert==nil) {
Myalert = [[Uialertview alloc] Initwithtitle:nil
Message: @ "read ..."
Delegate:self
Cancelbuttontitle:nil
Otherbuttontitles:nil];
Uiactivityindicatorview *activityview = [[Uiactivityindicatorview alloc] Initwithactivityindicatorstyle: Uiactivityindicatorviewstylewhite];
Activityview.frame = CGRectMake (120.f, 48.0f, 38.0f, 38.0f);
[Myalert Addsubview:activityview];
[ActivityView startanimating];
[Myalert show];
}
}
-(void) Webviewdidfinishload: (UIWebView *) webview{
[Myalert dismisswithclickedbuttonindex:0 Animated:yes];
}
Method Three: Use UIWebView to load GIF pictures, unless you want to use WebView, otherwise do not use this method to implement
Copy Code code as follows:
NSData *gif = [NSData datawithcontentsoffile: [[NSBundle Mainbundle] pathforresource:@ "1" oftype:@ "GIF"]];
View Build
UIWebView *webview = [[UIWebView alloc] initwithframe:cgrectmake (100, 100, 70, 30)];
webview.userinteractionenabled = no;//User is not interactive
[WebView loaddata:gif mimetype:@ "Image/gif" Textencodingname:nil Baseurl:nil];
[Self.view Addsubview:webview];
The above mentioned is the entire content of this article, I hope you can enjoy.