Skip to content

Instantly share code, notes, and snippets.

@cnsoft
Created July 2, 2013 17:26
Show Gist options
  • Select an option

  • Save cnsoft/5911269 to your computer and use it in GitHub Desktop.

Select an option

Save cnsoft/5911269 to your computer and use it in GitHub Desktop.
UIWebView NSURLConnection NSURLResponse 用法.
//
http://ioscreator.com/loading-a-website-with-uiwebview/
Now modify the ViewDidLoad method in ViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
//1
NSString *urlString = @"http://ioscreator.com";
//2
NSURL *url = [NSURL URLWithString:urlString];
//3
NSURLRequest *request = [NSURLRequest requestWithURL:url];
//4
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
//5
[NSURLConnection sendAsynchronousRequest:request queue:queue
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if ([data length] > 0 && error == nil) [myWebView loadRequest:request];
else if (error != nil) NSLog(@"Error: %@", error);
}];
}
http://blog.csdn.net/totogo2010/article/details/7686164
Delphi FMX Webrowser 如何使用 NSURLConnection
- (void)viewDidLoad
{
[super viewDidLoad];
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];
[self.view addSubview: webView];
[webView loadRequest:request];
}
@cnsoft

cnsoft commented Jul 2, 2013

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment