Thursday, May 5, 2011

opening an URL in safari while iPhone button is clicked

Hello,

I want to add a button to my iPhone application which will open an URL in safari on iPhone when clicked (my application will terminate right?)

Thanks.

Raihan

From stackoverflow
  • Your app will close if you are simply opening in Safari.

    You can, however, use a WebView control to embed the web browser in your app. This way your app will not terminate.

    ebaccount : Thanks for your reply. However, the application needs to be in that way. Could you let me know what API I need to call so that the URL is opened in safari and my application is closed?
  • You need to use - (BOOL)openURL:(NSURL *)url in UIApplication.

    UIApplication is a singleton, so your code would look something like this:

    NSURL *url;
    [[UIApplication sharedApplication] openURL:url];
    
    ebaccount : Thanks it worked.

0 comments:

Post a Comment