打开网站Url连接

-(IBAction)openWeb{

    NSString *urlText = [ [ NSString stringWithFormat:@"http://ditu.google.cn/"];

    [ [ UIApplication sharedApplication] openURL:[ NSURL urlWithString:urlText];

}

-(IBAction)openWeb{

    NSString *addressText = @"tian an men,bei jing,China";

    addressText = [ addressText stringByAddingpercentEscapesUsingEncoding:NSASCIIStringEncoding];

    NSString *urlText = [ NSString stringWithFormat:@"http://maps.google.com/maps?q = %@",addressText];

    webView.userInteractionEnabled = true;

    [webView loadRequest:[ [ NSURLRequest alloc] initWithURL:[ [ NSURL alloc] initWithString:urlText] ] ];

}

你可能感兴趣的:(c,c,objective,objective,打开网页,iOS基础,iOS基础)