title: openURL not opening safari to from app
body: <p>I have to clarify that I know how to open url from our iOS app, like </p>
  
  <pre><code>[[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlAddress]];
  </code></pre>
  
  <p>In my code I have done the same. It is an old app and I have to upgrade this app right now. I'm working on Xcode 7 right now. It has a code to open my website from the app. For that I have coded below for my website. I have also tried fro all other main site url but it still not opening safari to open this page.</p>
  
  <pre><code>    NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
      if([[UIApplication sharedApplication] canOpenURL:url]) {
          NSLog(@"OK");
          [[UIApplication sharedApplication] openURL:url];
      } else {
          NSLog(@"Failed to open url: http://www.google.com");
      }
  </code></pre>
  
  <p>I have printed it that it goes in condition <code>canOpenURL:url</code> and it prints <code>OK</code> but it will not redirect to safari. I have checked in simulator and also in device but the result is same. Please help. Thanks in advance. </p>
  
  <p>==== EDIT =======</p>
  
  <p>This may be helpful more information about app.</p>
  
  <p>It is tabbarcontroller app and navigation bar is shown for all views.</p>
  
  <p>The above code is in button action</p>
  
  <pre><code>-(IBAction)onSiteClick:(id)sender
  {
          NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
          if([[UIApplication sharedApplication] canOpenURL:url]) {
              NSLog(@"OK");
              [[UIApplication sharedApplication] openURL:url];
          } else {
              NSLog(@"Failed to open url: http://www.google.com");
          }
  }
  </code></pre>
  
  <p>If I put this code in app delegate <code>didFinishLaunchingWithOptions</code> method then it open safari and works. But it is not working on button click. Even I have tried code in <code>viewDidLoad</code> and <code>viewWillAppear</code>, then also it is not working.</p>
  
  <p>===== EDIT 1  ====</p>
  
  <p>I have not found solution for this yet. So for now I have taken a web view inside app and open the link in app.</p>