zoukankan      html  css  js  c++  java
  • iOS 本地加载js文件

     1 #import "RootViewController.h"
     2 
     3 @interface RootViewController ()<UIWebViewDelegate>
     4 
     5 @property (nonatomic, strong)UIWebView *webView;
     6 
     7 @end
     8 
     9 @implementation RootViewController
    10 
    11 - (void)dealloc
    12 {
    13     self.webView = nil;
    14 }
    15 - (void)viewDidLoad {
    16     [super viewDidLoad];
    17     self.view.backgroundColor = [UIColor redColor];
    18     self.webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    19     [self.view addSubview:self.webView];
    20     // cli_dwr.html文件名
    21     [self loadDocument:@"cli_dwr.html"];
    22 }
    23 // 加载本地使用说明文件
    24 - (void)loadDocument:(NSString *)docName
    25 {
    26     NSString *mainBundleDirectory = [[NSBundle mainBundle] bundlePath];
    27     NSString *path = [mainBundleDirectory stringByAppendingPathComponent:docName];
    28     
    29     NSURL *url = [NSURL fileURLWithPath:path];
    30     NSURLRequest *request = [NSURLRequest requestWithURL:url];
    31     self.webView.scalesPageToFit = YES;
    32     [self.webView loadRequest:request];
    33 }
    34 
    35 @end
  • 相关阅读:
    CSS-16-margin值重叠问题
    CSS-15-定位
    CSS-14-浮动
    CSS-13-块级元素和行内元素
    CSS-12-盒子模型
    CSS-11-外边距
    CSS-10-内边距
    CSS-09-背景属性
    CSS-08-边框属性设置
    CSS-07-CSS文本设置
  • 原文地址:https://www.cnblogs.com/lantu1989/p/4643834.html
Copyright © 2011-2022 走看看