Iphone – Disable Back and Forward button on UIToolBar in UIWebview

iphoneuiwebview

i am new to iphone. i want to disable Back(left arrow button) and Forward(right arrow button) button on UIToolBar in UIWebView. After moved web page want enable back button and then Forward button want to enable when its need. in my app, i am using toolbar at bottom side via interface builder. please any one help me!

Best Answer

Send the following message to the button object to enable/disable:

// Enable 
[myButton setEnabled:YES];

// Disable
[myButton setEnabled:NO];

To determine whether you should show these buttons you should check the following properties on the webview:

[myWebView canGoBack];
[myWebView canGoForward];

You'll want to check these whenever the user loads a page. To do so implement the UIWebViewDelegate method webViewDidFinishLoad:

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
  // Enable or disable back
  [myBackButton setEnabled:[myWebView canGoBack]];

  // Enable or disable forward
  [myForwardButton setEnabled:[myWebView canGoForward]];

 }
Related Topic