zoukankan      html  css  js  c++  java
  • IOS开发之路二十一(UIWebView加载本地html)

    挺简单不多说的直接代码:


    //
    //  ViewController.h
    //  JSAndJson
    //
    //  Created by WildCat on 13-9-8.
    //  Copyright (c) 2013年 wildcat. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController
    @property (nonatomic, strong) UIWebView *myWebView;
    @end
    

    //
    //  ViewController.m
    //  JSAndJson
    //
    //  Created by WildCat on 13-9-8.
    //  Copyright (c) 2013年 wildcat. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    @synthesize myWebView;
    //加载app中html函数
    - (void)loadDocument:(NSString*)docName {
        
      
        NSString *mainBundleDirectory = [[NSBundle mainBundle] bundlePath];
        NSString *path = [mainBundleDirectory  stringByAppendingPathComponent:docName];
        NSURL *url = [NSURL fileURLWithPath:path];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        self.myWebView.scalesPageToFit = YES;
        [self.myWebView loadRequest:request];
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor whiteColor];
        self.myWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
        self.myWebView.scalesPageToFit = YES;
        [self.view addSubview:self.myWebView];
        //app中的html
        [self loadDocument:@"test.html"];
        
        }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }
    
    @end
    


  • 相关阅读:
    hive 数据hadoop数据etl交换
    团队冲刺(三)
    团队冲刺(二)
    CVPR2019论文热词云的实现
    团队冲刺(一)
    团队开发之电梯演讲----团队项目介绍--“益青春APP”
    android的finish()方法
    java web项目通过外网ip访问
    MySQL出现错误1205-Lock wait timeout exceeded; try restarting transaction
    团队开发(自己的理解)
  • 原文地址:https://www.cnblogs.com/lixingle/p/3312960.html
Copyright © 2011-2022 走看看