tags:

views:

323

answers:

2

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

+3  A: 

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.

Kekoa
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?
ebaccount
+6  A: 

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];
pgb
Thanks it worked.
ebaccount