I want to launch safari browser from my IOS app with an specific url whe开发者_如何学Cn I press a button.
Is that possible?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
Use this code for launching the URL in the Safari Browser,
NSString* url = @"http://example.com";
UIApplication* app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:url]];
Sure you can!
Use the - (BOOL)openURL:(NSURL *)url
method of UIApplication
. You can get an instance of UIApplication
using the static method + sharedApplication
.
精彩评论