码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发webView的使用一

时间:2016-09-12 00:36:04      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self test5];
}

-(void)test1
{
    NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
    //加载网页
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
}

-(void)test2
{
    NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
    //加载网页
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
    
    self.webView.scrollView.contentInset = UIEdgeInsetsMake(40, 0, 0, 0);
}

//加载本地的文件
-(void)test3
{
    NSURL *url = [NSURL fileURLWithPath:@"/Users/xiaomage/Desktop/07-NSURLSession.pptx"];
    //加载网页
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
}

-(void)test4
{
    NSURL *url = [NSURL URLWithString:@"http://www.520it.com/"];
    //加载网页
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
    
    //设置时候自适应
    self.webView.scalesPageToFit = YES;
}

-(void)test5
{
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"text.html" withExtension:nil];
    
    //加载网页
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
    
    //设置时候自适应
    self.webView.dataDetectorTypes = UIDataDetectorTypeAll;
}
@end

 

iOS开发webView的使用一

标签:

原文地址:http://www.cnblogs.com/cqb-learner/p/5863255.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!