UIWebView常用命令

  1. 加载外部链接:
    NSURL *url = [NSURL URLWithString:@"https://www.apple.com"];
    NSURLRequest *req = [NSURLRequest requestWithURL:url];
    [self.webview loadRequest:req];
  1. 加载本地资源:
    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"CrazyDrag" ofType:@"html"];
    NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
    NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
    [self.webview loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];

你可能感兴趣的:(UIWebView常用命令)