title: how to disable hyperlink and copy/paste menu on iOS and webviewdidfinishload not called
body: <p>I'm trying to disable hyperlink and copy/paste menu on iOS UIwebview
  so I googled and there were a lot of answers.
  then I encountered with another problem 'webviewdidfinishload not called'
  so I add my code to ask your help. (Iam sure I properly connected IBOutlet)</p>
  
  <p>In additional, I still not get the idea of putting mainWebView.delegate = self instead of self.mainWebView.delegate = self 
  could anyone explain the difference?
  so iam not sure my other functions like 
      [[[mainWebView subviews] lastObject] setScrollEnabled:YES]
      [[[mainWebView subviews] lastObject] setScrollsToTop:NO]<br>
      mainWebView.scalesPageToFit = YES
  these are working or not.</p>
  
  <p>it should be working on ios5 to ios6.1
  thank you</p>
  
  <p>in .h file</p>
  
  <pre><code>@interface HRViewController : UIViewController &lt;UIWebViewDelegate&gt;
  {
      UIWebView *mainWebView;
  }
  @property (strong, nonatomic) IBOutlet UIWebView *mainWebView;
  
  @end
  </code></pre>
  
  <hr>
  
  <p>in .m file</p>
  
  <pre><code>@interface HRViewController ()
  
  @end
  
  @implementation HRViewController
  
  @synthesize mainWebView;
  
  - (void)viewDidLoad
  {
      [self startWebView];
      [super viewDidLoad];
  }
  
  - (void)startWebView
  {
      mainWebView.delegate = self;
  
      [[[mainWebView subviews] lastObject] setScrollEnabled:YES];
      [[[mainWebView subviews] lastObject] setScrollsToTop:NO]; 
      mainWebView.scalesPageToFit = YES;
  
      mainWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
      mainWebView.scalesPageToFit = YES;
      [self.view addSubview:self.mainWebView];
  
      NSURL *url = [NSURL URLWithString:/" @"http://www.mysite.com" "/];
      NSURLRequest *request = [NSURLRequest requestWithURL:url];
  
      [mainWebView loadRequest:request];
  }
  
  - (void)webViewDidFinishLoad:(UIWebView *)WebView {
      NSLog(@"finish");
  
      [WebView stringByEvaluatingJavaScriptFromString: @"document.documentElement.style.webkitUserSelect='none';"];
      [WebView stringByEvaluatingJavaScriptFromString: @"document.documentElement.style.webkitTouchCallout='none';"];
  }
  
  - (void)webViewDidStartLoad:(UIWebView *)mainWebView {
      NSLog(@"start");
  }
  
  - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
      NSLog(@"Error for WEBVIEW: %@", [error description]);
  }
  </code></pre>
  
  <p>EDIED
  I used below codes but still doesnt work...
  none of these doesnt work!!!!!</p>
  
  <pre><code>- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
  {
      NSLog(@"canPerformAction: %@",NSStringFromSelector(action));
      if (action == @selector(copy:) ||
          action == @selector(paste:)||
          action == @selector(cut:)) {
          return NO;
      }
      return NO;
  }
  </code></pre>
  
  <p>and this    </p>
  
  <pre><code>- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
  {
      UIMenuController *menuController = [UIMenuController sharedMenuController];
      if (menuController) {
          [UIMenuController sharedMenuController].menuVisible = NO;
      }
      return NO;
  }
  </code></pre>
  
  <p>even this
      - (void)viewDidLoad {
          mainWebView.delegate = self;
      }</p>
  
  <pre><code>- (void)webViewDidFinishLoad:(UIWebView *)webView {
      NSLog(@"finish");
      // Disable user selection
      [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
      // Disable callout
      [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
  }
  </code></pre>
  
  <p>also this
      - (void)viewDidLoad {
          [self longPress:self.mainWebView];
      }</p>
  
  <pre><code>- (void)longPress:(UIView *)webView {
      UILongPressGestureRecognizer* longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress)];
  
      longPress.allowableMovement=100;
      longPress.minimumPressDuration=0.3;
      longPress.delaysTouchesBegan=YES;
      longPress.cancelsTouchesInView=YES; 
      [webView addGestureRecognizer:longPress]; 
  }
  
  // I just need this for the selector in the gesture recognizer.
  - (void)handleLongPress {
  
  }
  </code></pre>
  
  <p>Please help me.. it drives me crazy for a week now..</p>