Created
July 2, 2013 17:26
-
-
Save cnsoft/5911269 to your computer and use it in GitHub Desktop.
UIWebView NSURLConnection NSURLResponse 用法.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| 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]; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://blog.cnrainbird.com/index.php/2012/03/22/wei_wbsharekit_zeng_jia_cheng_xu_nei_deng_lu_ren_zheng_uiwebview/