开发者

What is the problem with the back button in my UIWebView?

I have an issue in my application that i wrote coding for the back button in my webView setEnabled = NO, but when the application is launched and webViewDidFinishLoad the back button setEnabled = YES. I tried all possibility to set the back button enabled is equal false but it not开发者_JAVA技巧 works.

   -(IBAction) backButton : (id) sender{
                backTapped = YES;
                [webView goBack];
            }
   -(IBAction) fwdButton : (id) sender{
                forwardTapped = YES;
                [webView goForward];
             }

   - (void)webViewDidStartLoad:(UIWebView *)thisWebView{
                    NSLog(@"webViewDidStartLoad");
                [progressWheel startAnimating]; 
                progressWheel.hidden = NO;
                if(!backTapped){
                                    back.enabled = NO;
                    }
                if (!forwardTapped) {
                            forward.enabled = NO;   
                    }
                 }

     - (void)webViewDidFinishLoad:(UIWebView *)thisWebView
      {
                   [progressWheel stopAnimating]; 
               progressWheel.hidden = YES;

               if (!backTapped) {
                            [back setEnabled:thisWebView.canGoBack];
                            back.showsTouchWhenHighlighted = YES;
                      } 

               if (!forwardTapped) {
                            [forward setEnabled:thisWebView.canGoForward];
                            forward.showsTouchWhenHighlighted = YES;
                    }

     }


I can't actually quite understand the problem you are having, but I can see two potential issues:

1) You set backTapped and forwardTapped to YES, but never set them to NO anywhere.

2) Perhaps you don't have "back" or "forward" buttons wired in you xib - if they are nil then back.enabled = NO will do nothing.

Edit:

This logic seems backwards:

if (!backTapped)
   back.enabled = NO;

In your code you set backTapped to YES, then this code is hit so !backTapped is ! YES which is NO.

Try

if (backTapped)
   back.enabled = NO;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜