oc里使用JQuery 和 bootstrap

来源:互联网 发布:linux# 编辑:程序博客网 时间:2024/06/14 15:30

突然想把Jquery 和 bootstrap这两个框架拖到iOS工程。试了试竟然可以使用:

1 将两个框架复制到工程中

2 写好html代码

3 更改js 和css link的路径




2简单写几个标签测试用

<!DOCTYPE html>

<html>

<head>

<metacharset="utf-8" />

<title></title>

<linkrel="stylesheet"href="/Users/yst911521/Desktop/jqueryandOC/jqueryandOC/bootstrap-3.3.2-dist/css/bootstrap-theme.min.css" />

</head>

<body>

<!-- Split button -->

<div class="btn-group">

  <button type="button"class="btn btn-danger">Action</button>

  <button type="button"class="btn btn-danger dropdown-toggle"data-toggle="dropdown">

    <span class="caret"></span>

    <span class="sr-only">Toggle Dropdown</span>

  </button>

  

  

  

  

  <!--JQURE-->

  

  <p id="11">2143242</p>

  <div class="22">GTRYHTJUUYY</div>

  <div class="div">111</div>

  

  

<script type="text/javascript"src="/Users/yst911521/Desktop/jqueryandOC/jqueryandOC/bootstrap-3.3.2-dist/jQueryDownload/jquery-3.1.1.min.js" ></script>

  

  <script type="text/javascript">

//$('.div').hide();

//$('.22').hide();


</script>


</body>

</html>

3web加载

#import "ViewController.h"


@interface ViewController ()

@property(nonatomic,strong)UIWebView*webview;


@end


@implementation ViewController


- (void)viewDidLoad {

    [superviewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

//   /Users/yst911521/Desktop/jqueryandOC/jqueryandOC/bootstrap-3.3.2-dist/jQueryDownload/jquery-3.1.1.min.js

//    /Users/yst911521/Desktop/jqueryandOC/jqueryandOC/bootstrap-3.3.2-dist/css/bootstrap-theme.min.css

    

    self.view.backgroundColor=[UIColorredColor];

    

    

    self.webview =[[UIWebViewalloc]initWithFrame:self.view.bounds];

    [self.viewaddSubview:self.webview];

    

    NSURL*url =[[NSBundlemainBundle]URLForResource:@"index"withExtension:@"html"];

    NSURLRequest*request =[NSURLRequestrequestWithURL:url];

    

    [self.webviewloadRequest:request];

}



bootstrap 红色button已经出现说明可以使用

注意更改 link路径 为本地路径

<link rel="stylesheet"href="/Users/yst****/Desktop/jqueryandOC/jqueryandOC/bootstrap-3.3.2-dist/css/bootstrap-theme.min.css" />


下面测试 jQuery

//更改本地路径

<script type="text/javascript"src="/Users/yst9*****/Desktop/jqueryandOC/jqueryandOC/bootstrap-3.3.2-dist/jQueryDownload/jquery-3.1.1.min.js" ></script>

web加载

注释掉这两句隐藏两个标签

//$('.div').hide();

//$('.22').hide();

运行结果


注意最下面两行 存在

//$('.div').hide();

//$('.22').hide();

打开这两句隐藏事件 保存 -> 运行



刚才用jQurey 语法隐藏的标签被隐藏了。


这样iOS中可以运用这两个框架。更多功能自己去发掘吧。







0 0
原创粉丝点击