Instead of loading a URL into a UIWebView we can also launch Safari to display it:
1 2 3 |
UIApplication *mySafari = [UIApplication sharedApplication]; NSURL *myURL = [[NSURL alloc]initWithString:@"http://www.mydomain.com"]; [mySafari openURL:myURL]; |
The method returns a BOOL value which will feed back if this operation was a success or not:
1 2 3 4 |
if (![mySafari openURL:myURL]) { // opening didn't work } |
openURL can open phone numbers (tel:), mailto: links, http: and https: links.
Hey i m trying to launch directly safari, without creating view controller. So i have written this code in didFinishLaunchingWithOptions: But it taking lot of time to open. Please help
Pass I’m afraid – it’s not a real world scenario though because you wouldn’t open Safari as soon as your app launches (users might as well launch Safari right away). Perhaps add a button that will trigger opening the URL. It should happen instantly.