IOS implements its own web browser (canGoBack), ioscangoback
Create a UIWebView, define the forward, backward, and refresh buttons, and implement the UIWebViewDelegate method.
1. Back button event
-(IBAction) WebViewBack :( id) sender
{
If ([self. webview canGoBack]) {
[Self. webview goBack];
}
}
2. forward button event
-(IBAction) WebViewForward :( id) sender
{
If ([self. webview canGoForward])
[Self. webview goForward];
}
3. Refresh events
-(IBAction) WebViewRefresh :( id) sender
{
[Self. webview reload];
}
4. UIWebViewDelegate proxy method webViewDidFinishLoad
-(Void) webViewDidFinishLoad :( UIWebView *) webView1
{
NSString * title = [webView1 stringByEvaluatingJavaScriptFromString: @ "document. title"];
_ WebviewTitleLabel. text = title;
If (! [WebView1 canGoBack])
{
_ BtnWebviewGoBack. enabled = NO;
}
Else
{
_ BtnWebviewGoBack. enabled = YES;
}
If (! [WebView1 canGoForward])
{
_ BtnWebviewGoForward. enabled = NO;
}
Else
{
_ BtnWebviewGoForward. enabled = YES;
} // Determine whether forward or backward can be performed after webView is loaded to determine whether the backward key and forward key are available.
[_ Indicator stopRotateAnimation]; // stop rotating and refreshing the image
[_ LoadingView stopAnimating_LoadingView]; // stop the rotation of LoadingView
}
5. UIWebViewDelegate proxy method webViewDidStartLoad
-(Void) webViewDidStartLoad :( UIWebView *) webView
{
[_ Indicator startAnimating]; // starts rotating the refreshed image
[_ LoadingView startAnimating_LoadingView]; // starts the rotation of LoadingView
}