├── .DS_Store
├── .gitignore
├── Android-WebView-JavaScript
├── .gitignore
├── .idea
│ ├── codeStyles
│ │ └── Project.xml
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── encodings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── org
│ │ │ └── skyfox
│ │ │ └── android_webview_javascript
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── assets
│ │ │ └── JSWebView.html
│ │ ├── java
│ │ │ └── org
│ │ │ │ └── skyfox
│ │ │ │ └── android_webview_javascript
│ │ │ │ └── MainActivity.java
│ │ └── res
│ │ │ ├── layout
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── skyfox
│ │ └── android_webview_javascript
│ │ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── README.md
├── demo.png
├── iOS-WebView-JavaScript.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcshareddata
│ │ └── WebViewJS.xccheckout
│ └── xcuserdata
│ │ ├── Jakey.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
│ │ └── runlin.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── Jakey.xcuserdatad
│ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ │ ├── iOS-WebView-JavaScript.xcscheme
│ │ └── xcschememanagement.plist
│ └── runlin.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── iOS-WebView-JavaScript.xcscheme
│ └── xcschememanagement.plist
└── iOS-WebView-JavaScript
├── AppDelegate.h
├── AppDelegate.m
├── Images.xcassets
├── AppIcon.appiconset
│ └── Contents.json
└── LaunchImage.launchimage
│ └── Contents.json
├── JavaScriptCore
├── HighcharsWebView
│ ├── HighchartsView.html
│ ├── HighchartsWebViewController.h
│ ├── HighchartsWebViewController.m
│ ├── HighchartsWebViewController.xib
│ ├── highcharts.js
│ └── jquery-1.11.0.min.js
├── JSCallOC
│ ├── JSCallOC.html
│ ├── JSCallOCViewController.h
│ ├── JSCallOCViewController.m
│ └── JSCallOCViewController.xib
├── OCCallJS
│ ├── OCCallJSViewController.h
│ ├── OCCallJSViewController.m
│ ├── OCCallJSViewController.xib
│ └── test.js
├── SecondViewController.h
├── SecondViewController.m
└── SecondViewController.xib
├── Launch Screen.storyboard
├── RootViewController.h
├── RootViewController.m
├── RootViewController.xib
├── UIWebView
├── Category
│ ├── WebView+Alert.h
│ └── WebView+Alert.m
├── JSUIWebView.html
├── JSUIWebViewViewController.h
├── JSUIWebViewViewController.m
├── JSUIWebViewViewController.xib
├── UIWebViewJS.html
├── UIWebViewJSViewController.h
├── UIWebViewJSViewController.m
├── UIWebViewJSViewController.xib
├── UIWebViewJS_file.html
├── UIWebViewJS_location.html
├── light_advice.png
└── light_illstration.png
├── WKWebView
├── JSWKWebView.html
├── JSWKWebViewViewController.h
├── JSWKWebViewViewController.m
├── JSWKWebViewViewController.xib
├── WKWebViewJS.html
├── WKWebViewJSViewController.h
├── WKWebViewJSViewController.m
├── WKWebViewJSViewController.xib
├── WKWebViewJS_file.html
└── WKWebViewJS_location.html
├── en.lproj
└── InfoPlist.strings
├── iOS-WebView-JavaScript-Info.plist
├── iOS-WebView-JavaScript-Prefix.pch
└── main.m
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | WebViewJS.xcodeproj/xcuserdata/Jakey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
21 |
22 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "org.skyfox.android_webview_javascript"
8 | minSdkVersion 15
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:28.0.0'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | }
31 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/runlin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/androidTest/java/org/skyfox/android_webview_javascript/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package org.skyfox.android_webview_javascript;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("org.skyfox.android_webview_javascript", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/assets/JSWebView.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/java/org/skyfox/android_webview_javascript/MainActivity.java:
--------------------------------------------------------------------------------
1 | package org.skyfox.android_webview_javascript;
2 |
3 | import android.os.Build;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.webkit.JavascriptInterface;
8 | import android.webkit.WebChromeClient;
9 | import android.webkit.WebSettings;
10 | import android.webkit.WebView;
11 | import android.widget.Toast;
12 |
13 | import org.json.JSONObject;
14 |
15 | public class MainActivity extends AppCompatActivity {
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_main);
21 |
22 | WebView webview = (WebView) findViewById(R.id.webview);
23 | WebSettings webSettings = webview.getSettings();
24 | webSettings.setJavaScriptEnabled(true);
25 | webview.setWebChromeClient(new WebChromeClient()); //webview只是一个承载体,各种内容的渲染需要使用webviewChromClient去实现,所以set一个默认的基类WebChromeClient就行
26 | webview.addJavascriptInterface(this,"Native"); //注入Native对象到webview window中
27 |
28 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
29 | WebView.setWebContentsDebuggingEnabled(true);
30 | }
31 |
32 | webview.loadUrl("file:///android_asset/JSWebView.html");
33 |
34 |
35 | // webview.loadUrl("http://dev.skyfox.org/JSWebView.html");
36 | // webView.loadUrl("javascript:alert(Native.alert())");
37 | }
38 | @JavascriptInterface
39 | public void alert(String param){
40 | Log.i("alert",param.toString());
41 |
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android-WebView-JavaScript
3 |
4 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/app/src/test/java/org/skyfox/android_webview_javascript/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package org.skyfox.android_webview_javascript;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.0'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | google()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/Android-WebView-JavaScript/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 03 20:13:10 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Android-WebView-JavaScript/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOS UIWebView,WKWebView 与 JavaScript的深度交互
2 | - iOS-WebView-JavaScript 为iOS与JavaScript与JavaScript的深度交互
3 | - Android-WebView-JavaScript 与android与JavaScript与JavaScript的深度交互
4 |
5 |
6 |
7 | ### 1.WKWebView 不支持JavaScriptCore的方式但提供message handler的方式为JavaScript 与Objective-C 通信
8 |
9 | * WKWebView 与 JavaScript交互
10 | * JavaScript 与 WKWebView 交互
11 |
12 | ### 2.UIWebViews使用代理拦截或JavaScriptCore.framework进行交互
13 |
14 | * UIWebView 与 JavaScript交互
15 | * JavaScript 与 UIWebView 交互
16 |
17 | * UIWebView 与 JavaScriptCore.framework交互
18 | * JavaScriptCore.framework 与 UIWebView 交互
19 |
20 |
21 | #### 博文:http://www.skyfox.org/javascript-ios-navive-message.html
22 |
23 |
24 |
25 | 
26 |
27 |
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/demo.png
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | A2CB2E471CBA44B3003919C0 /* UIWebViewJS.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E3F1CBA44B3003919C0 /* UIWebViewJS.html */; };
11 | A2CB2E481CBA44B3003919C0 /* UIWebViewJS_file.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E401CBA44B3003919C0 /* UIWebViewJS_file.html */; };
12 | A2CB2E491CBA44B3003919C0 /* light_advice.png in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E411CBA44B3003919C0 /* light_advice.png */; };
13 | A2CB2E4A1CBA44B3003919C0 /* light_illstration.png in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E421CBA44B3003919C0 /* light_illstration.png */; };
14 | A2CB2E4B1CBA44B3003919C0 /* UIWebViewJS_location.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E431CBA44B3003919C0 /* UIWebViewJS_location.html */; };
15 | A2CB2E4C1CBA44B3003919C0 /* UIWebViewJSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E451CBA44B3003919C0 /* UIWebViewJSViewController.m */; };
16 | A2CB2E4D1CBA44B3003919C0 /* UIWebViewJSViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E461CBA44B3003919C0 /* UIWebViewJSViewController.xib */; };
17 | A2CB2E521CBA44F9003919C0 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E501CBA44F9003919C0 /* RootViewController.m */; };
18 | A2CB2E531CBA44F9003919C0 /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E511CBA44F9003919C0 /* RootViewController.xib */; };
19 | A2CB2E551CBA4547003919C0 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E541CBA4547003919C0 /* Launch Screen.storyboard */; };
20 | A2CB2E591CBA4683003919C0 /* WKWebViewJSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E571CBA4683003919C0 /* WKWebViewJSViewController.m */; };
21 | A2CB2E5A1CBA4683003919C0 /* WKWebViewJSViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E581CBA4683003919C0 /* WKWebViewJSViewController.xib */; };
22 | A2CB2E601CBA49CC003919C0 /* WKWebViewJS_file.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E5D1CBA49CC003919C0 /* WKWebViewJS_file.html */; };
23 | A2CB2E611CBA49CC003919C0 /* WKWebViewJS_location.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E5E1CBA49CC003919C0 /* WKWebViewJS_location.html */; };
24 | A2CB2E621CBA49CC003919C0 /* WKWebViewJS.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E5F1CBA49CC003919C0 /* WKWebViewJS.html */; };
25 | A2CB2E641CBA49F0003919C0 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2CB2E631CBA49F0003919C0 /* WebKit.framework */; };
26 | A2CB2E6A1CBA6198003919C0 /* JSWKWebViewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E681CBA6198003919C0 /* JSWKWebViewViewController.m */; };
27 | A2CB2E6B1CBA6198003919C0 /* JSWKWebViewViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E691CBA6198003919C0 /* JSWKWebViewViewController.xib */; };
28 | A2CB2E6F1CBA61A8003919C0 /* JSUIWebViewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E6D1CBA61A8003919C0 /* JSUIWebViewViewController.m */; };
29 | A2CB2E701CBA61A8003919C0 /* JSUIWebViewViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E6E1CBA61A8003919C0 /* JSUIWebViewViewController.xib */; };
30 | A2CB2E741CBA6248003919C0 /* WebView+Alert.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E731CBA6248003919C0 /* WebView+Alert.m */; };
31 | A2CB2E761CBA6444003919C0 /* JSWKWebView.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E751CBA6444003919C0 /* JSWKWebView.html */; };
32 | A2CB2E781CBA64E4003919C0 /* JSUIWebView.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E771CBA64E4003919C0 /* JSUIWebView.html */; };
33 | A2CB2E8C1CBA7184003919C0 /* highcharts.js in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E7D1CBA7184003919C0 /* highcharts.js */; };
34 | A2CB2E8D1CBA7184003919C0 /* HighchartsView.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E7E1CBA7184003919C0 /* HighchartsView.html */; };
35 | A2CB2E8E1CBA7184003919C0 /* HighchartsWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E801CBA7184003919C0 /* HighchartsWebViewController.m */; };
36 | A2CB2E8F1CBA7184003919C0 /* HighchartsWebViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E811CBA7184003919C0 /* HighchartsWebViewController.xib */; };
37 | A2CB2E901CBA7184003919C0 /* jquery-1.11.0.min.js in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E821CBA7184003919C0 /* jquery-1.11.0.min.js */; };
38 | A2CB2E911CBA7184003919C0 /* JSCallOC.html in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E841CBA7184003919C0 /* JSCallOC.html */; };
39 | A2CB2E921CBA7184003919C0 /* JSCallOCViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E861CBA7184003919C0 /* JSCallOCViewController.m */; };
40 | A2CB2E931CBA7184003919C0 /* JSCallOCViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E871CBA7184003919C0 /* JSCallOCViewController.xib */; };
41 | A2CB2E941CBA7184003919C0 /* OCCallJSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E8A1CBA7184003919C0 /* OCCallJSViewController.m */; };
42 | A2CB2E951CBA7184003919C0 /* OCCallJSViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E8B1CBA7184003919C0 /* OCCallJSViewController.xib */; };
43 | A2CB2E971CBA7196003919C0 /* test.js in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E961CBA7196003919C0 /* test.js */; };
44 | A2CB2E9B1CBA7252003919C0 /* SecondViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CB2E991CBA7252003919C0 /* SecondViewController.m */; };
45 | A2CB2E9C1CBA7252003919C0 /* SecondViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2CB2E9A1CBA7252003919C0 /* SecondViewController.xib */; };
46 | A2E71E0B197F911B0055B687 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2E71E0A197F911B0055B687 /* Foundation.framework */; };
47 | A2E71E0D197F911B0055B687 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2E71E0C197F911B0055B687 /* CoreGraphics.framework */; };
48 | A2E71E0F197F911B0055B687 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2E71E0E197F911B0055B687 /* UIKit.framework */; };
49 | A2E71E15197F911B0055B687 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A2E71E13197F911B0055B687 /* InfoPlist.strings */; };
50 | A2E71E17197F911B0055B687 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A2E71E16197F911B0055B687 /* main.m */; };
51 | A2E71E1B197F911B0055B687 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A2E71E1A197F911B0055B687 /* AppDelegate.m */; };
52 | A2E71E1D197F911B0055B687 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A2E71E1C197F911B0055B687 /* Images.xcassets */; };
53 | /* End PBXBuildFile section */
54 |
55 | /* Begin PBXFileReference section */
56 | A2CB2E3F1CBA44B3003919C0 /* UIWebViewJS.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = UIWebViewJS.html; sourceTree = ""; };
57 | A2CB2E401CBA44B3003919C0 /* UIWebViewJS_file.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = UIWebViewJS_file.html; sourceTree = ""; };
58 | A2CB2E411CBA44B3003919C0 /* light_advice.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = light_advice.png; sourceTree = ""; };
59 | A2CB2E421CBA44B3003919C0 /* light_illstration.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = light_illstration.png; sourceTree = ""; };
60 | A2CB2E431CBA44B3003919C0 /* UIWebViewJS_location.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = UIWebViewJS_location.html; sourceTree = ""; };
61 | A2CB2E441CBA44B3003919C0 /* UIWebViewJSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWebViewJSViewController.h; sourceTree = ""; };
62 | A2CB2E451CBA44B3003919C0 /* UIWebViewJSViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIWebViewJSViewController.m; sourceTree = ""; };
63 | A2CB2E461CBA44B3003919C0 /* UIWebViewJSViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UIWebViewJSViewController.xib; sourceTree = ""; };
64 | A2CB2E4F1CBA44F9003919C0 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; };
65 | A2CB2E501CBA44F9003919C0 /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; };
66 | A2CB2E511CBA44F9003919C0 /* RootViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = ""; };
67 | A2CB2E541CBA4547003919C0 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; };
68 | A2CB2E561CBA4683003919C0 /* WKWebViewJSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJSViewController.h; sourceTree = ""; };
69 | A2CB2E571CBA4683003919C0 /* WKWebViewJSViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJSViewController.m; sourceTree = ""; };
70 | A2CB2E581CBA4683003919C0 /* WKWebViewJSViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WKWebViewJSViewController.xib; sourceTree = ""; };
71 | A2CB2E5D1CBA49CC003919C0 /* WKWebViewJS_file.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WKWebViewJS_file.html; sourceTree = ""; };
72 | A2CB2E5E1CBA49CC003919C0 /* WKWebViewJS_location.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WKWebViewJS_location.html; sourceTree = ""; };
73 | A2CB2E5F1CBA49CC003919C0 /* WKWebViewJS.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WKWebViewJS.html; sourceTree = ""; };
74 | A2CB2E631CBA49F0003919C0 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
75 | A2CB2E671CBA6198003919C0 /* JSWKWebViewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWKWebViewViewController.h; sourceTree = ""; };
76 | A2CB2E681CBA6198003919C0 /* JSWKWebViewViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSWKWebViewViewController.m; sourceTree = ""; };
77 | A2CB2E691CBA6198003919C0 /* JSWKWebViewViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JSWKWebViewViewController.xib; sourceTree = ""; };
78 | A2CB2E6C1CBA61A8003919C0 /* JSUIWebViewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUIWebViewViewController.h; sourceTree = ""; };
79 | A2CB2E6D1CBA61A8003919C0 /* JSUIWebViewViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSUIWebViewViewController.m; sourceTree = ""; };
80 | A2CB2E6E1CBA61A8003919C0 /* JSUIWebViewViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JSUIWebViewViewController.xib; sourceTree = ""; };
81 | A2CB2E721CBA6248003919C0 /* WebView+Alert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WebView+Alert.h"; sourceTree = ""; };
82 | A2CB2E731CBA6248003919C0 /* WebView+Alert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "WebView+Alert.m"; sourceTree = ""; };
83 | A2CB2E751CBA6444003919C0 /* JSWKWebView.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = JSWKWebView.html; sourceTree = ""; };
84 | A2CB2E771CBA64E4003919C0 /* JSUIWebView.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = JSUIWebView.html; sourceTree = ""; };
85 | A2CB2E7D1CBA7184003919C0 /* highcharts.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = highcharts.js; sourceTree = ""; };
86 | A2CB2E7E1CBA7184003919C0 /* HighchartsView.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HighchartsView.html; sourceTree = ""; };
87 | A2CB2E7F1CBA7184003919C0 /* HighchartsWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HighchartsWebViewController.h; sourceTree = ""; };
88 | A2CB2E801CBA7184003919C0 /* HighchartsWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HighchartsWebViewController.m; sourceTree = ""; };
89 | A2CB2E811CBA7184003919C0 /* HighchartsWebViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HighchartsWebViewController.xib; sourceTree = ""; };
90 | A2CB2E821CBA7184003919C0 /* jquery-1.11.0.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "jquery-1.11.0.min.js"; sourceTree = ""; };
91 | A2CB2E841CBA7184003919C0 /* JSCallOC.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = JSCallOC.html; sourceTree = ""; };
92 | A2CB2E851CBA7184003919C0 /* JSCallOCViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallOCViewController.h; sourceTree = ""; };
93 | A2CB2E861CBA7184003919C0 /* JSCallOCViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSCallOCViewController.m; sourceTree = ""; };
94 | A2CB2E871CBA7184003919C0 /* JSCallOCViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JSCallOCViewController.xib; sourceTree = ""; };
95 | A2CB2E891CBA7184003919C0 /* OCCallJSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCCallJSViewController.h; sourceTree = ""; };
96 | A2CB2E8A1CBA7184003919C0 /* OCCallJSViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCCallJSViewController.m; sourceTree = ""; };
97 | A2CB2E8B1CBA7184003919C0 /* OCCallJSViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OCCallJSViewController.xib; sourceTree = ""; };
98 | A2CB2E961CBA7196003919C0 /* test.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = test.js; sourceTree = ""; };
99 | A2CB2E981CBA7252003919C0 /* SecondViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecondViewController.h; sourceTree = ""; };
100 | A2CB2E991CBA7252003919C0 /* SecondViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecondViewController.m; sourceTree = ""; };
101 | A2CB2E9A1CBA7252003919C0 /* SecondViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SecondViewController.xib; sourceTree = ""; };
102 | A2E71E07197F911B0055B687 /* iOS-WebView-JavaScript.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS-WebView-JavaScript.app"; sourceTree = BUILT_PRODUCTS_DIR; };
103 | A2E71E0A197F911B0055B687 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
104 | A2E71E0C197F911B0055B687 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
105 | A2E71E0E197F911B0055B687 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
106 | A2E71E12197F911B0055B687 /* iOS-WebView-JavaScript-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "iOS-WebView-JavaScript-Info.plist"; sourceTree = ""; };
107 | A2E71E14197F911B0055B687 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
108 | A2E71E16197F911B0055B687 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
109 | A2E71E18197F911B0055B687 /* iOS-WebView-JavaScript-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "iOS-WebView-JavaScript-Prefix.pch"; sourceTree = ""; };
110 | A2E71E19197F911B0055B687 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
111 | A2E71E1A197F911B0055B687 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
112 | A2E71E1C197F911B0055B687 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
113 | A2E71E23197F911B0055B687 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
114 | /* End PBXFileReference section */
115 |
116 | /* Begin PBXFrameworksBuildPhase section */
117 | A2E71E04197F911B0055B687 /* Frameworks */ = {
118 | isa = PBXFrameworksBuildPhase;
119 | buildActionMask = 2147483647;
120 | files = (
121 | A2CB2E641CBA49F0003919C0 /* WebKit.framework in Frameworks */,
122 | A2E71E0D197F911B0055B687 /* CoreGraphics.framework in Frameworks */,
123 | A2E71E0F197F911B0055B687 /* UIKit.framework in Frameworks */,
124 | A2E71E0B197F911B0055B687 /* Foundation.framework in Frameworks */,
125 | );
126 | runOnlyForDeploymentPostprocessing = 0;
127 | };
128 | /* End PBXFrameworksBuildPhase section */
129 |
130 | /* Begin PBXGroup section */
131 | A2CB2E3E1CBA44B3003919C0 /* UIWebView */ = {
132 | isa = PBXGroup;
133 | children = (
134 | A2CB2E711CBA6248003919C0 /* Category */,
135 | A2CB2E661CBA615E003919C0 /* JS to UIWebView */,
136 | A2CB2E5C1CBA4815003919C0 /* UIWebView to JS */,
137 | A2CB2E411CBA44B3003919C0 /* light_advice.png */,
138 | A2CB2E421CBA44B3003919C0 /* light_illstration.png */,
139 | A2CB2E431CBA44B3003919C0 /* UIWebViewJS_location.html */,
140 | A2CB2E401CBA44B3003919C0 /* UIWebViewJS_file.html */,
141 | );
142 | path = UIWebView;
143 | sourceTree = "";
144 | };
145 | A2CB2E4E1CBA44BE003919C0 /* WKWebView */ = {
146 | isa = PBXGroup;
147 | children = (
148 | A2CB2E651CBA6150003919C0 /* JS to WKWebView */,
149 | A2CB2E5B1CBA4804003919C0 /* WKWebView to JS */,
150 | A2CB2E5E1CBA49CC003919C0 /* WKWebViewJS_location.html */,
151 | A2CB2E5F1CBA49CC003919C0 /* WKWebViewJS.html */,
152 | );
153 | path = WKWebView;
154 | sourceTree = "";
155 | };
156 | A2CB2E5B1CBA4804003919C0 /* WKWebView to JS */ = {
157 | isa = PBXGroup;
158 | children = (
159 | A2CB2E5D1CBA49CC003919C0 /* WKWebViewJS_file.html */,
160 | A2CB2E561CBA4683003919C0 /* WKWebViewJSViewController.h */,
161 | A2CB2E571CBA4683003919C0 /* WKWebViewJSViewController.m */,
162 | A2CB2E581CBA4683003919C0 /* WKWebViewJSViewController.xib */,
163 | );
164 | name = "WKWebView to JS";
165 | sourceTree = "";
166 | };
167 | A2CB2E5C1CBA4815003919C0 /* UIWebView to JS */ = {
168 | isa = PBXGroup;
169 | children = (
170 | A2CB2E3F1CBA44B3003919C0 /* UIWebViewJS.html */,
171 | A2CB2E441CBA44B3003919C0 /* UIWebViewJSViewController.h */,
172 | A2CB2E451CBA44B3003919C0 /* UIWebViewJSViewController.m */,
173 | A2CB2E461CBA44B3003919C0 /* UIWebViewJSViewController.xib */,
174 | );
175 | name = "UIWebView to JS";
176 | sourceTree = "";
177 | };
178 | A2CB2E651CBA6150003919C0 /* JS to WKWebView */ = {
179 | isa = PBXGroup;
180 | children = (
181 | A2CB2E751CBA6444003919C0 /* JSWKWebView.html */,
182 | A2CB2E671CBA6198003919C0 /* JSWKWebViewViewController.h */,
183 | A2CB2E681CBA6198003919C0 /* JSWKWebViewViewController.m */,
184 | A2CB2E691CBA6198003919C0 /* JSWKWebViewViewController.xib */,
185 | );
186 | name = "JS to WKWebView";
187 | sourceTree = "";
188 | };
189 | A2CB2E661CBA615E003919C0 /* JS to UIWebView */ = {
190 | isa = PBXGroup;
191 | children = (
192 | A2CB2E771CBA64E4003919C0 /* JSUIWebView.html */,
193 | A2CB2E6C1CBA61A8003919C0 /* JSUIWebViewViewController.h */,
194 | A2CB2E6D1CBA61A8003919C0 /* JSUIWebViewViewController.m */,
195 | A2CB2E6E1CBA61A8003919C0 /* JSUIWebViewViewController.xib */,
196 | );
197 | name = "JS to UIWebView";
198 | sourceTree = "";
199 | };
200 | A2CB2E711CBA6248003919C0 /* Category */ = {
201 | isa = PBXGroup;
202 | children = (
203 | A2CB2E721CBA6248003919C0 /* WebView+Alert.h */,
204 | A2CB2E731CBA6248003919C0 /* WebView+Alert.m */,
205 | );
206 | path = Category;
207 | sourceTree = "";
208 | };
209 | A2CB2E7B1CBA7178003919C0 /* JavaScriptCore */ = {
210 | isa = PBXGroup;
211 | children = (
212 | A2CB2E981CBA7252003919C0 /* SecondViewController.h */,
213 | A2CB2E991CBA7252003919C0 /* SecondViewController.m */,
214 | A2CB2E9A1CBA7252003919C0 /* SecondViewController.xib */,
215 | A2CB2E7C1CBA7184003919C0 /* HighcharsWebView */,
216 | A2CB2E831CBA7184003919C0 /* JSCallOC */,
217 | A2CB2E881CBA7184003919C0 /* OCCallJS */,
218 | );
219 | path = JavaScriptCore;
220 | sourceTree = "";
221 | };
222 | A2CB2E7C1CBA7184003919C0 /* HighcharsWebView */ = {
223 | isa = PBXGroup;
224 | children = (
225 | A2CB2E7D1CBA7184003919C0 /* highcharts.js */,
226 | A2CB2E7E1CBA7184003919C0 /* HighchartsView.html */,
227 | A2CB2E7F1CBA7184003919C0 /* HighchartsWebViewController.h */,
228 | A2CB2E801CBA7184003919C0 /* HighchartsWebViewController.m */,
229 | A2CB2E811CBA7184003919C0 /* HighchartsWebViewController.xib */,
230 | A2CB2E821CBA7184003919C0 /* jquery-1.11.0.min.js */,
231 | );
232 | path = HighcharsWebView;
233 | sourceTree = "";
234 | };
235 | A2CB2E831CBA7184003919C0 /* JSCallOC */ = {
236 | isa = PBXGroup;
237 | children = (
238 | A2CB2E841CBA7184003919C0 /* JSCallOC.html */,
239 | A2CB2E851CBA7184003919C0 /* JSCallOCViewController.h */,
240 | A2CB2E861CBA7184003919C0 /* JSCallOCViewController.m */,
241 | A2CB2E871CBA7184003919C0 /* JSCallOCViewController.xib */,
242 | );
243 | path = JSCallOC;
244 | sourceTree = "";
245 | };
246 | A2CB2E881CBA7184003919C0 /* OCCallJS */ = {
247 | isa = PBXGroup;
248 | children = (
249 | A2CB2E961CBA7196003919C0 /* test.js */,
250 | A2CB2E891CBA7184003919C0 /* OCCallJSViewController.h */,
251 | A2CB2E8A1CBA7184003919C0 /* OCCallJSViewController.m */,
252 | A2CB2E8B1CBA7184003919C0 /* OCCallJSViewController.xib */,
253 | );
254 | path = OCCallJS;
255 | sourceTree = "";
256 | };
257 | A2E71DFE197F911B0055B687 = {
258 | isa = PBXGroup;
259 | children = (
260 | A2E71E10197F911B0055B687 /* iOS-WebView-JavaScript */,
261 | A2E71E09197F911B0055B687 /* Frameworks */,
262 | A2E71E08197F911B0055B687 /* Products */,
263 | );
264 | sourceTree = "";
265 | };
266 | A2E71E08197F911B0055B687 /* Products */ = {
267 | isa = PBXGroup;
268 | children = (
269 | A2E71E07197F911B0055B687 /* iOS-WebView-JavaScript.app */,
270 | );
271 | name = Products;
272 | sourceTree = "";
273 | };
274 | A2E71E09197F911B0055B687 /* Frameworks */ = {
275 | isa = PBXGroup;
276 | children = (
277 | A2CB2E631CBA49F0003919C0 /* WebKit.framework */,
278 | A2E71E0A197F911B0055B687 /* Foundation.framework */,
279 | A2E71E0C197F911B0055B687 /* CoreGraphics.framework */,
280 | A2E71E0E197F911B0055B687 /* UIKit.framework */,
281 | A2E71E23197F911B0055B687 /* XCTest.framework */,
282 | );
283 | name = Frameworks;
284 | sourceTree = "";
285 | };
286 | A2E71E10197F911B0055B687 /* iOS-WebView-JavaScript */ = {
287 | isa = PBXGroup;
288 | children = (
289 | A2CB2E7B1CBA7178003919C0 /* JavaScriptCore */,
290 | A2CB2E4E1CBA44BE003919C0 /* WKWebView */,
291 | A2CB2E3E1CBA44B3003919C0 /* UIWebView */,
292 | A2E71E19197F911B0055B687 /* AppDelegate.h */,
293 | A2E71E1A197F911B0055B687 /* AppDelegate.m */,
294 | A2CB2E4F1CBA44F9003919C0 /* RootViewController.h */,
295 | A2CB2E501CBA44F9003919C0 /* RootViewController.m */,
296 | A2CB2E511CBA44F9003919C0 /* RootViewController.xib */,
297 | A2E71E1C197F911B0055B687 /* Images.xcassets */,
298 | A2E71E11197F911B0055B687 /* Supporting Files */,
299 | );
300 | name = "iOS-WebView-JavaScript";
301 | path = iOS-WebView-JavaScript;
302 | sourceTree = "";
303 | };
304 | A2E71E11197F911B0055B687 /* Supporting Files */ = {
305 | isa = PBXGroup;
306 | children = (
307 | A2E71E12197F911B0055B687 /* iOS-WebView-JavaScript-Info.plist */,
308 | A2E71E13197F911B0055B687 /* InfoPlist.strings */,
309 | A2E71E16197F911B0055B687 /* main.m */,
310 | A2E71E18197F911B0055B687 /* iOS-WebView-JavaScript-Prefix.pch */,
311 | A2CB2E541CBA4547003919C0 /* Launch Screen.storyboard */,
312 | );
313 | name = "Supporting Files";
314 | sourceTree = "";
315 | };
316 | /* End PBXGroup section */
317 |
318 | /* Begin PBXNativeTarget section */
319 | A2E71E06197F911B0055B687 /* iOS-WebView-JavaScript */ = {
320 | isa = PBXNativeTarget;
321 | buildConfigurationList = A2E71E33197F911B0055B687 /* Build configuration list for PBXNativeTarget "iOS-WebView-JavaScript" */;
322 | buildPhases = (
323 | A2E71E03197F911B0055B687 /* Sources */,
324 | A2E71E04197F911B0055B687 /* Frameworks */,
325 | A2E71E05197F911B0055B687 /* Resources */,
326 | );
327 | buildRules = (
328 | );
329 | dependencies = (
330 | );
331 | name = "iOS-WebView-JavaScript";
332 | productName = iOS-WebView-JavaScript;
333 | productReference = A2E71E07197F911B0055B687 /* iOS-WebView-JavaScript.app */;
334 | productType = "com.apple.product-type.application";
335 | };
336 | /* End PBXNativeTarget section */
337 |
338 | /* Begin PBXProject section */
339 | A2E71DFF197F911B0055B687 /* Project object */ = {
340 | isa = PBXProject;
341 | attributes = {
342 | LastUpgradeCheck = 0500;
343 | ORGANIZATIONNAME = www.skyfox.org;
344 | };
345 | buildConfigurationList = A2E71E02197F911B0055B687 /* Build configuration list for PBXProject "iOS-WebView-JavaScript" */;
346 | compatibilityVersion = "Xcode 3.2";
347 | developmentRegion = English;
348 | hasScannedForEncodings = 0;
349 | knownRegions = (
350 | en,
351 | );
352 | mainGroup = A2E71DFE197F911B0055B687;
353 | productRefGroup = A2E71E08197F911B0055B687 /* Products */;
354 | projectDirPath = "";
355 | projectRoot = "";
356 | targets = (
357 | A2E71E06197F911B0055B687 /* iOS-WebView-JavaScript */,
358 | );
359 | };
360 | /* End PBXProject section */
361 |
362 | /* Begin PBXResourcesBuildPhase section */
363 | A2E71E05197F911B0055B687 /* Resources */ = {
364 | isa = PBXResourcesBuildPhase;
365 | buildActionMask = 2147483647;
366 | files = (
367 | A2CB2E951CBA7184003919C0 /* OCCallJSViewController.xib in Resources */,
368 | A2CB2E5A1CBA4683003919C0 /* WKWebViewJSViewController.xib in Resources */,
369 | A2CB2E701CBA61A8003919C0 /* JSUIWebViewViewController.xib in Resources */,
370 | A2CB2E8F1CBA7184003919C0 /* HighchartsWebViewController.xib in Resources */,
371 | A2CB2E491CBA44B3003919C0 /* light_advice.png in Resources */,
372 | A2CB2E9C1CBA7252003919C0 /* SecondViewController.xib in Resources */,
373 | A2CB2E481CBA44B3003919C0 /* UIWebViewJS_file.html in Resources */,
374 | A2CB2E4D1CBA44B3003919C0 /* UIWebViewJSViewController.xib in Resources */,
375 | A2E71E15197F911B0055B687 /* InfoPlist.strings in Resources */,
376 | A2CB2E621CBA49CC003919C0 /* WKWebViewJS.html in Resources */,
377 | A2CB2E781CBA64E4003919C0 /* JSUIWebView.html in Resources */,
378 | A2CB2E471CBA44B3003919C0 /* UIWebViewJS.html in Resources */,
379 | A2CB2E531CBA44F9003919C0 /* RootViewController.xib in Resources */,
380 | A2CB2E971CBA7196003919C0 /* test.js in Resources */,
381 | A2CB2E601CBA49CC003919C0 /* WKWebViewJS_file.html in Resources */,
382 | A2CB2E911CBA7184003919C0 /* JSCallOC.html in Resources */,
383 | A2CB2E611CBA49CC003919C0 /* WKWebViewJS_location.html in Resources */,
384 | A2CB2E6B1CBA6198003919C0 /* JSWKWebViewViewController.xib in Resources */,
385 | A2CB2E8C1CBA7184003919C0 /* highcharts.js in Resources */,
386 | A2CB2E4B1CBA44B3003919C0 /* UIWebViewJS_location.html in Resources */,
387 | A2CB2E761CBA6444003919C0 /* JSWKWebView.html in Resources */,
388 | A2CB2E4A1CBA44B3003919C0 /* light_illstration.png in Resources */,
389 | A2CB2E551CBA4547003919C0 /* Launch Screen.storyboard in Resources */,
390 | A2CB2E8D1CBA7184003919C0 /* HighchartsView.html in Resources */,
391 | A2CB2E931CBA7184003919C0 /* JSCallOCViewController.xib in Resources */,
392 | A2E71E1D197F911B0055B687 /* Images.xcassets in Resources */,
393 | A2CB2E901CBA7184003919C0 /* jquery-1.11.0.min.js in Resources */,
394 | );
395 | runOnlyForDeploymentPostprocessing = 0;
396 | };
397 | /* End PBXResourcesBuildPhase section */
398 |
399 | /* Begin PBXSourcesBuildPhase section */
400 | A2E71E03197F911B0055B687 /* Sources */ = {
401 | isa = PBXSourcesBuildPhase;
402 | buildActionMask = 2147483647;
403 | files = (
404 | A2CB2E9B1CBA7252003919C0 /* SecondViewController.m in Sources */,
405 | A2CB2E4C1CBA44B3003919C0 /* UIWebViewJSViewController.m in Sources */,
406 | A2CB2E521CBA44F9003919C0 /* RootViewController.m in Sources */,
407 | A2E71E1B197F911B0055B687 /* AppDelegate.m in Sources */,
408 | A2CB2E921CBA7184003919C0 /* JSCallOCViewController.m in Sources */,
409 | A2CB2E6A1CBA6198003919C0 /* JSWKWebViewViewController.m in Sources */,
410 | A2CB2E941CBA7184003919C0 /* OCCallJSViewController.m in Sources */,
411 | A2CB2E741CBA6248003919C0 /* WebView+Alert.m in Sources */,
412 | A2CB2E8E1CBA7184003919C0 /* HighchartsWebViewController.m in Sources */,
413 | A2E71E17197F911B0055B687 /* main.m in Sources */,
414 | A2CB2E591CBA4683003919C0 /* WKWebViewJSViewController.m in Sources */,
415 | A2CB2E6F1CBA61A8003919C0 /* JSUIWebViewViewController.m in Sources */,
416 | );
417 | runOnlyForDeploymentPostprocessing = 0;
418 | };
419 | /* End PBXSourcesBuildPhase section */
420 |
421 | /* Begin PBXVariantGroup section */
422 | A2E71E13197F911B0055B687 /* InfoPlist.strings */ = {
423 | isa = PBXVariantGroup;
424 | children = (
425 | A2E71E14197F911B0055B687 /* en */,
426 | );
427 | name = InfoPlist.strings;
428 | sourceTree = "";
429 | };
430 | /* End PBXVariantGroup section */
431 |
432 | /* Begin XCBuildConfiguration section */
433 | A2E71E31197F911B0055B687 /* Debug */ = {
434 | isa = XCBuildConfiguration;
435 | buildSettings = {
436 | ALWAYS_SEARCH_USER_PATHS = NO;
437 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
438 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
439 | CLANG_CXX_LIBRARY = "libc++";
440 | CLANG_ENABLE_MODULES = YES;
441 | CLANG_ENABLE_OBJC_ARC = YES;
442 | CLANG_WARN_BOOL_CONVERSION = YES;
443 | CLANG_WARN_CONSTANT_CONVERSION = YES;
444 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
445 | CLANG_WARN_EMPTY_BODY = YES;
446 | CLANG_WARN_ENUM_CONVERSION = YES;
447 | CLANG_WARN_INT_CONVERSION = YES;
448 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
449 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
450 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
451 | COPY_PHASE_STRIP = NO;
452 | GCC_C_LANGUAGE_STANDARD = gnu99;
453 | GCC_DYNAMIC_NO_PIC = NO;
454 | GCC_OPTIMIZATION_LEVEL = 0;
455 | GCC_PREPROCESSOR_DEFINITIONS = (
456 | "DEBUG=1",
457 | "$(inherited)",
458 | );
459 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
460 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
461 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
462 | GCC_WARN_UNDECLARED_SELECTOR = YES;
463 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
464 | GCC_WARN_UNUSED_FUNCTION = YES;
465 | GCC_WARN_UNUSED_VARIABLE = YES;
466 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
467 | ONLY_ACTIVE_ARCH = YES;
468 | SDKROOT = iphoneos;
469 | };
470 | name = Debug;
471 | };
472 | A2E71E32197F911B0055B687 /* Release */ = {
473 | isa = XCBuildConfiguration;
474 | buildSettings = {
475 | ALWAYS_SEARCH_USER_PATHS = NO;
476 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
477 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
478 | CLANG_CXX_LIBRARY = "libc++";
479 | CLANG_ENABLE_MODULES = YES;
480 | CLANG_ENABLE_OBJC_ARC = YES;
481 | CLANG_WARN_BOOL_CONVERSION = YES;
482 | CLANG_WARN_CONSTANT_CONVERSION = YES;
483 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
484 | CLANG_WARN_EMPTY_BODY = YES;
485 | CLANG_WARN_ENUM_CONVERSION = YES;
486 | CLANG_WARN_INT_CONVERSION = YES;
487 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
488 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
489 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
490 | COPY_PHASE_STRIP = YES;
491 | ENABLE_NS_ASSERTIONS = NO;
492 | GCC_C_LANGUAGE_STANDARD = gnu99;
493 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
494 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
495 | GCC_WARN_UNDECLARED_SELECTOR = YES;
496 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
497 | GCC_WARN_UNUSED_FUNCTION = YES;
498 | GCC_WARN_UNUSED_VARIABLE = YES;
499 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
500 | SDKROOT = iphoneos;
501 | VALIDATE_PRODUCT = YES;
502 | };
503 | name = Release;
504 | };
505 | A2E71E34197F911B0055B687 /* Debug */ = {
506 | isa = XCBuildConfiguration;
507 | buildSettings = {
508 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
509 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
510 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
511 | GCC_PREFIX_HEADER = "iOS-WebView-JavaScript/iOS-WebView-JavaScript-Prefix.pch";
512 | INFOPLIST_FILE = "iOS-WebView-JavaScript/iOS-WebView-JavaScript-Info.plist";
513 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
514 | PRODUCT_NAME = "iOS-WebView-JavaScript";
515 | WRAPPER_EXTENSION = app;
516 | };
517 | name = Debug;
518 | };
519 | A2E71E35197F911B0055B687 /* Release */ = {
520 | isa = XCBuildConfiguration;
521 | buildSettings = {
522 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
523 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
524 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
525 | GCC_PREFIX_HEADER = "iOS-WebView-JavaScript/iOS-WebView-JavaScript-Prefix.pch";
526 | INFOPLIST_FILE = "iOS-WebView-JavaScript/iOS-WebView-JavaScript-Info.plist";
527 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
528 | PRODUCT_NAME = "iOS-WebView-JavaScript";
529 | WRAPPER_EXTENSION = app;
530 | };
531 | name = Release;
532 | };
533 | /* End XCBuildConfiguration section */
534 |
535 | /* Begin XCConfigurationList section */
536 | A2E71E02197F911B0055B687 /* Build configuration list for PBXProject "iOS-WebView-JavaScript" */ = {
537 | isa = XCConfigurationList;
538 | buildConfigurations = (
539 | A2E71E31197F911B0055B687 /* Debug */,
540 | A2E71E32197F911B0055B687 /* Release */,
541 | );
542 | defaultConfigurationIsVisible = 0;
543 | defaultConfigurationName = Release;
544 | };
545 | A2E71E33197F911B0055B687 /* Build configuration list for PBXNativeTarget "iOS-WebView-JavaScript" */ = {
546 | isa = XCConfigurationList;
547 | buildConfigurations = (
548 | A2E71E34197F911B0055B687 /* Debug */,
549 | A2E71E35197F911B0055B687 /* Release */,
550 | );
551 | defaultConfigurationIsVisible = 0;
552 | defaultConfigurationName = Release;
553 | };
554 | /* End XCConfigurationList section */
555 | };
556 | rootObject = A2E71DFF197F911B0055B687 /* Project object */;
557 | }
558 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/project.xcworkspace/xcshareddata/WebViewJS.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | 0636D6FC-E2AE-4C7B-918B-15B8A4549528
9 | IDESourceControlProjectName
10 | WebViewJS
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | C07EBB92-9DB3-43B4-992E-97D9951F44BC
14 | https://github.com/shaojiankui/WebViewJS
15 |
16 | IDESourceControlProjectPath
17 | WebViewJS.xcodeproj/project.xcworkspace
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | C07EBB92-9DB3-43B4-992E-97D9951F44BC
21 | ../..
22 |
23 | IDESourceControlProjectURL
24 | https://github.com/shaojiankui/WebViewJS
25 | IDESourceControlProjectVersion
26 | 110
27 | IDESourceControlProjectWCCIdentifier
28 | C07EBB92-9DB3-43B4-992E-97D9951F44BC
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | C07EBB92-9DB3-43B4-992E-97D9951F44BC
36 | IDESourceControlWCCName
37 | WebViewJS
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/project.xcworkspace/xcuserdata/Jakey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/iOS-WebView-JavaScript.xcodeproj/project.xcworkspace/xcuserdata/Jakey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/project.xcworkspace/xcuserdata/runlin.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/iOS-WebView-JavaScript.xcodeproj/project.xcworkspace/xcuserdata/runlin.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/xcuserdata/Jakey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/xcuserdata/Jakey.xcuserdatad/xcschemes/iOS-WebView-JavaScript.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/xcuserdata/Jakey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | iOS-WebView-JavaScript.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | A2E71E06197F911B0055B687
16 |
17 | primary
18 |
19 |
20 | A2E71E21197F911B0055B687
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/xcuserdata/runlin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/xcuserdata/runlin.xcuserdatad/xcschemes/iOS-WebView-JavaScript.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript.xcodeproj/xcuserdata/runlin.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | iOS-WebView-JavaScript.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | A2E71E06197F911B0055B687
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 14-7-23.
6 | // Copyright (c) 2014年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RootViewController.h"
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 | @property (strong, nonatomic) RootViewController *viewController;
15 | @end
16 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // WebViewJS
4 | //
5 | // Created by jakey on 14-5-27.
6 | // Copyright (c) 2014年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "RootViewController.h"
12 |
13 | @implementation AppDelegate
14 |
15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
16 | {
17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
18 | // Override point for customization after application launch.
19 | self.viewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
20 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
21 | [self.window makeKeyAndVisible];
22 | return YES;
23 | }
24 |
25 | - (void)applicationWillResignActive:(UIApplication *)application
26 | {
27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
29 | }
30 |
31 | - (void)applicationDidEnterBackground:(UIApplication *)application
32 | {
33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
35 | }
36 |
37 | - (void)applicationWillEnterForeground:(UIApplication *)application
38 | {
39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
40 | }
41 |
42 | - (void)applicationDidBecomeActive:(UIApplication *)application
43 | {
44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
45 | }
46 |
47 | - (void)applicationWillTerminate:(UIApplication *)application
48 | {
49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/HighcharsWebView/HighchartsView.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Highcharts Sample
11 |
12 |
33 |
34 |
35 |
36 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/HighcharsWebView/HighchartsWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // HighchartsWebViewController.h
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface HighchartsWebViewController : UIViewController
13 | @property (weak, nonatomic) IBOutlet UIWebView *webView;
14 | @property (strong, nonatomic) JSContext *context;
15 | @end
16 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/HighcharsWebView/HighchartsWebViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // HighchartsWebViewController.m
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import "HighchartsWebViewController.h"
10 |
11 | @interface HighchartsWebViewController ()
12 |
13 | @end
14 |
15 | @implementation HighchartsWebViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view from its nib.
20 |
21 | NSString *path = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"HighchartsView.html"];
22 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]];
23 |
24 | [self.webView loadRequest:request];
25 | }
26 |
27 | #pragma mark - UIWebViewDelegate
28 | - (void)webViewDidFinishLoad:(UIWebView *)webView
29 | {
30 | // 以 html title 设置 导航栏 title
31 | self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
32 |
33 | // 禁用 页面元素选择
34 | //[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
35 |
36 | // 禁用 长按弹出ActionSheet
37 | //[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
38 |
39 |
40 | // 关联 JSContext
41 | self.context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
42 |
43 | // 打印异常
44 | self.context.exceptionHandler =
45 | ^(JSContext *context, JSValue *exceptionValue)
46 | {
47 | context.exception = exceptionValue;
48 | NSLog(@"%@", exceptionValue);
49 | };
50 |
51 |
52 | // 装载数据
53 | [self loadChartsData];
54 | }
55 |
56 | #pragma mark - Load Charts Data
57 |
58 | - (void)loadChartsData
59 | {
60 | // 装载数据
61 | NSArray *the1024Data = @[@33, @41, @32, @51, @42, @103, @136];
62 | NSDictionary *the1024Dict = @{@"name": @"1024", @"data": the1024Data};
63 |
64 | NSArray *theCCAVData = @[@8, @11, @21, @13, @20, @52, @43];
65 | NSDictionary *theCCAVDict = @{@"name": @"CCAV", @"data": theCCAVData};
66 |
67 | NSArray *seriesArray = @[the1024Dict, theCCAVDict];
68 |
69 | [self.context[@"drawChart"] callWithArguments:@[seriesArray]];
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/HighcharsWebView/HighchartsWebViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/JSCallOC/JSCallOC.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | JSCallOC
9 |
10 |
34 |
35 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | 输入一个整数:
50 |
51 |
52 |
53 |
54 |
55 | 结果:
56 |
57 |
58 |
59 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/JSCallOC/JSCallOCViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // JSCallOCViewController.h
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @protocol TestJSExport
13 | JSExportAs
14 | (calculateForJS /** handleFactorialCalculateWithNumber 作为js方法的别名 */,
15 | - (void)handleFactorialCalculateWithNumber:(NSString *)number
16 | );
17 | - (void)pushViewController:(NSString *)view title:(NSString *)title;
18 | @end
19 |
20 |
21 |
22 | @interface JSCallOCViewController : UIViewController
23 | @property (weak, nonatomic) IBOutlet UIWebView *webView;
24 | @property (strong, nonatomic) JSContext *context;
25 | @end
26 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/JSCallOC/JSCallOCViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // JSCallOCViewController.m
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import "JSCallOCViewController.h"
10 | #import "SecondViewController.h"
11 | @interface JSCallOCViewController ()
12 |
13 | @end
14 |
15 | @implementation JSCallOCViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view from its nib.
30 | self.title = @"js call oc";
31 |
32 | NSString *path = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"JSCallOC.html"];
33 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]];
34 | [self.webView loadRequest:request];
35 | }
36 |
37 | #pragma mark - UIWebViewDelegate
38 |
39 | - (void)webViewDidFinishLoad:(UIWebView *)webView
40 | {
41 | // 以 html title 设置 导航栏 title
42 | self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
43 | // Undocumented access to UIWebView's JSContext
44 | self.context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
45 | // 打印异常
46 | self.context.exceptionHandler =
47 | ^(JSContext *context, JSValue *exceptionValue)
48 | {
49 | context.exception = exceptionValue;
50 | NSLog(@"%@", exceptionValue);
51 | };
52 |
53 | // 以 JSExport 协议关联 native 的方法
54 | self.context[@"app"] = self;
55 |
56 | // 以 block 形式关联 JavaScript function
57 | self.context[@"log"] =
58 | ^(NSString *str)
59 | {
60 | NSLog(@"%@", str);
61 | };
62 |
63 | // 以 block 形式关联 JavaScript function
64 | self.context[@"alert"] =
65 | ^(NSString *str)
66 | {
67 | UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"msg from js" message:str delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
68 | [alert show];
69 | };
70 |
71 | __block typeof(self) weakSelf = self;
72 | self.context[@"addSubView"] =
73 | ^(NSString *viewname)
74 | {
75 | UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, 500, 300, 100)];
76 | view.backgroundColor = [UIColor redColor];
77 | UISwitch *sw = [[UISwitch alloc]init];
78 | [view addSubview:sw];
79 | [weakSelf.view addSubview:view];
80 | };
81 | //多参数
82 | self.context[@"mutiParams"] =
83 | ^(NSString *a,NSString *b,NSString *c)
84 | {
85 | NSLog(@"%@ %@ %@",a,b,c);
86 | };
87 |
88 | }
89 |
90 | #pragma mark - JSExport Methods
91 |
92 | - (void)handleFactorialCalculateWithNumber:(NSString *)number
93 | {
94 | NSLog(@"%@", number);
95 |
96 | NSNumber *result = [self calculateFactorialOfNumber:@([number integerValue])];
97 |
98 | NSLog(@"%@", result);
99 |
100 | [self.context[@"showResult"] callWithArguments:@[result]];
101 | }
102 |
103 | - (void)pushViewController:(NSString *)view title:(NSString *)title
104 | {
105 | Class second = NSClassFromString(view);
106 | id secondVC = [[second alloc]init];
107 | ((UIViewController*)secondVC).title = title;
108 | [self.navigationController pushViewController:secondVC animated:YES];
109 | }
110 |
111 | #pragma mark - Factorial Method
112 |
113 | - (NSNumber *)calculateFactorialOfNumber:(NSNumber *)number
114 | {
115 | NSInteger i = [number integerValue];
116 | if (i < 0)
117 | {
118 | return [NSNumber numberWithInteger:0];
119 | }
120 | if (i == 0)
121 | {
122 | return [NSNumber numberWithInteger:1];
123 | }
124 |
125 | NSInteger r = (i * [(NSNumber *)[self calculateFactorialOfNumber:[NSNumber numberWithInteger:(i - 1)]] integerValue]);
126 |
127 | return [NSNumber numberWithInteger:r];
128 | }
129 |
130 |
131 |
132 | @end
133 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/JSCallOC/JSCallOCViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/OCCallJS/OCCallJSViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // OCCallJSViewController.h
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface OCCallJSViewController : UIViewController
13 | - (IBAction)sendToJS:(id)sender;
14 | @property (weak, nonatomic) IBOutlet UILabel *showLable;
15 | @property (weak, nonatomic) IBOutlet UITextField *textField;
16 | @property (strong, nonatomic) JSContext *context;
17 | @end
18 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/OCCallJS/OCCallJSViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // OCCallJSViewController.m
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import "OCCallJSViewController.h"
10 |
11 | @interface OCCallJSViewController ()
12 |
13 | @end
14 |
15 | @implementation OCCallJSViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view from its nib.
30 | self.title = @"oc call js";
31 | self.context = [[JSContext alloc] init];
32 | [self.context evaluateScript:[self loadJsFile:@"test"]];
33 |
34 |
35 | }
36 | - (NSString *)loadJsFile:(NSString*)fileName
37 | {
38 | NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"js"];
39 | NSString *jsScript = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
40 | return jsScript;
41 | }
42 | - (void)didReceiveMemoryWarning
43 | {
44 | [super didReceiveMemoryWarning];
45 | // Dispose of any resources that can be recreated.
46 | }
47 |
48 | - (IBAction)sendToJS:(id)sender {
49 | NSNumber *inputNumber = [NSNumber numberWithInteger:[self.textField.text integerValue]];
50 | JSValue *function = [self.context objectForKeyedSubscript:@"factorial"];
51 | JSValue *result = [function callWithArguments:@[inputNumber]];
52 | self.showLable.text = [NSString stringWithFormat:@"%@", [result toNumber]];
53 | }
54 |
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/OCCallJS/OCCallJSViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/OCCallJS/test.js:
--------------------------------------------------------------------------------
1 | var factorial = function(n) {
2 |
3 | if (n < 0)
4 |
5 | return;
6 |
7 | if (n === 0)
8 |
9 | return 1;
10 |
11 | return n * factorial(n - 1)
12 |
13 | };
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/SecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.h
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SecondViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/SecondViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SecondViewController.m
3 | // JavaScriptCore-Demo
4 | //
5 | // Created by Jakey on 14/12/26.
6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7 | //
8 |
9 | #import "SecondViewController.h"
10 |
11 | @interface SecondViewController ()
12 |
13 | @end
14 |
15 | @implementation SecondViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view from its nib.
20 | }
21 |
22 | - (void)didReceiveMemoryWarning {
23 | [super didReceiveMemoryWarning];
24 | // Dispose of any resources that can be recreated.
25 | }
26 |
27 | /*
28 | #pragma mark - Navigation
29 |
30 | // In a storyboard-based application, you will often want to do a little preparation before navigation
31 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
32 | // Get the new view controller using [segue destinationViewController].
33 | // Pass the selected object to the new view controller.
34 | }
35 | */
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/JavaScriptCore/SecondViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/Launch Screen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
26 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/RootViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RootViewController.h
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RootViewController : UIViewController
12 | - (IBAction)UIWebviewToJS:(id)sender;
13 | - (IBAction)JSToUIWebview:(id)sender;
14 |
15 |
16 | - (IBAction)WKWebViewToJS:(id)sender;
17 | - (IBAction)JSToWKWebView:(id)sender;
18 |
19 | - (IBAction)JSCallOC:(id)sender;
20 | - (IBAction)OCCallJS:(id)sender;
21 | - (IBAction)HighchartsWeb:(id)sender;
22 | @end
23 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/RootViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // RootViewController.m
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import "RootViewController.h"
10 | #import "UIWebViewJSViewController.h"
11 | #import "WKWebViewJSViewController.h"
12 |
13 | #import "JSUIWebViewViewController.h"
14 | #import "JSWKWebViewViewController.h"
15 |
16 | #import "JSCallOCViewController.h"
17 | #import "OCCallJSViewController.h"
18 | #import "HighchartsWebViewController.h"
19 |
20 | @interface RootViewController ()
21 |
22 | @end
23 |
24 | @implementation RootViewController
25 |
26 | - (void)viewDidLoad {
27 | [super viewDidLoad];
28 | // Do any additional setup after loading the view from its nib.
29 | self.title = @"WebView&JavaScript的交互通信";
30 | }
31 |
32 | - (void)didReceiveMemoryWarning {
33 | [super didReceiveMemoryWarning];
34 | // Dispose of any resources that can be recreated.
35 | }
36 |
37 | /*
38 | #pragma mark - Navigation
39 |
40 | // In a storyboard-based application, you will often want to do a little preparation before navigation
41 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
42 | // Get the new view controller using [segue destinationViewController].
43 | // Pass the selected object to the new view controller.
44 | }
45 | */
46 |
47 | - (IBAction)UIWebviewToJS:(id)sender {
48 | UIWebViewJSViewController *webView = [[UIWebViewJSViewController alloc]initWithNibName:@"UIWebViewJSViewController" bundle:nil];
49 | [self.navigationController pushViewController:webView animated:YES];
50 | }
51 |
52 | - (IBAction)JSToUIWebview:(id)sender {
53 | JSUIWebViewViewController *js = [[JSUIWebViewViewController alloc]init];
54 | [self.navigationController pushViewController:js animated:YES];
55 | }
56 |
57 | - (IBAction)WKWebViewToJS:(id)sender {
58 | WKWebViewJSViewController *webView = [[WKWebViewJSViewController alloc]initWithNibName:@"WKWebViewJSViewController" bundle:nil];
59 | [self.navigationController pushViewController:webView animated:YES];
60 | }
61 |
62 | - (IBAction)JSToWKWebView:(id)sender {
63 | JSWKWebViewViewController *js = [[JSWKWebViewViewController alloc]init];
64 | [self.navigationController pushViewController:js animated:YES];
65 | }
66 |
67 |
68 |
69 | - (IBAction)JSCallOC:(id)sender {
70 | JSCallOCViewController *jsCallOC = [[JSCallOCViewController alloc]init];
71 | [self.navigationController pushViewController:jsCallOC animated:YES];
72 | }
73 |
74 | - (IBAction)OCCallJS:(id)sender {
75 | OCCallJSViewController *ocCallJS = [[OCCallJSViewController alloc]init];
76 | [self.navigationController pushViewController:ocCallJS animated:YES];
77 | }
78 |
79 | - (IBAction)HighchartsWeb:(id)sender {
80 | HighchartsWebViewController *highchartsWeb =[[HighchartsWebViewController alloc]init];
81 | [self.navigationController pushViewController:highchartsWeb animated:YES];
82 | }
83 | @end
84 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/RootViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
35 |
48 |
61 |
74 |
87 |
96 |
105 |
114 |
124 |
137 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/Category/WebView+Alert.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebView+Alert.h
3 | // AlertProject
4 | //
5 | // Created by Peter.Kang on 14-1-23.
6 | // Copyright (c) 2014年 Peter.Kang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIWebView (JavaScriptAlert)
12 | -(void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
13 |
14 | -(BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
15 | @end
16 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/Category/WebView+Alert.m:
--------------------------------------------------------------------------------
1 | //
2 | // WebView+Alert.m
3 | // AlertProject
4 | //
5 | // Created by Peter.Kang on 14-1-23.
6 | // Copyright (c) 2014年 Peter.Kang. All rights reserved.
7 | //
8 |
9 | #import "WebView+Alert.h"
10 |
11 | @implementation UIWebView (JavaScriptAlert)
12 |
13 | static BOOL diagStat = NO;
14 |
15 | -(void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame{
16 | UIAlertView* dialogue = [[UIAlertView alloc]initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
17 | [dialogue show];;
18 | }
19 |
20 | -(BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame{
21 | UIAlertView* dialogue = [[UIAlertView alloc] initWithTitle:nil message:message delegate:self cancelButtonTitle:NSLocalizedString(@"Okay", @"Okay") otherButtonTitles:NSLocalizedString(@"Cancel", @"Cancel"), nil];
22 | [dialogue show];
23 | while (dialogue.hidden==NO && dialogue.superview!=nil) {
24 | [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01f]];
25 | }
26 |
27 | return diagStat;
28 | }
29 |
30 | -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
31 | if (buttonIndex==0) {
32 | diagStat=YES;
33 | }else if(buttonIndex==1){
34 | diagStat=NO;
35 | }
36 | }
37 | @end
38 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/JSUIWebView.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
47 |
48 |
49 | 方法1 document.location
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | 方法2 iframe .location
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/JSUIWebViewViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // JSUIWebViewViewController.h
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JSUIWebViewViewController : UIViewController
12 | @property (weak, nonatomic) IBOutlet UIWebView *myWebView;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/JSUIWebViewViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // JSUIWebViewViewController.m
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import "JSUIWebViewViewController.h"
10 |
11 | @interface JSUIWebViewViewController ()
12 |
13 | @end
14 |
15 | @implementation JSUIWebViewViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view from its nib.
20 | self.title = @"JS调用UIWebView";
21 | self.automaticallyAdjustsScrollViewInsets = NO;
22 |
23 | [self loadTouched:nil];
24 |
25 | }
26 | - (IBAction)loadTouched:(id)sender {
27 | [self loadHtml:@"JSUIWebView"];
28 | for (UIView *view in self.view.subviews) {
29 | if (view.tag == 11111) {
30 | [view removeFromSuperview];
31 | }
32 | }
33 | // [[self.view viewWithTag:11111] removeFromSuperview];
34 |
35 | }
36 | - (void)webViewDidFinishLoad: (UIWebView *) webView
37 | {
38 | //重定义web的alert方法,捕获webview弹出的原生alert 可以修改标题和内容等等
39 | [webView stringByEvaluatingJavaScriptFromString:@"window.alert = function(message) { window.location = \"myapp:&func=alert&message=\" + message; }"];
40 | }
41 | #pragma mark --
42 | #pragma mark UIWebViewDelegate
43 | /*
44 | * 方法的返回值是BOOL值。
45 | * 返回YES:表示让浏览器执行默认操作,比如某个a链接跳转
46 | * 返回NO:表示不执行浏览器的默认操作,这里因为通过url协议来判断js执行native的操作,肯定不是浏览器默认操作,故返回NO
47 | *
48 | */
49 |
50 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
51 |
52 | NSString *requestString = [[[request URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding ];
53 |
54 | if ([requestString hasPrefix:@"myapp:"]) {
55 | NSLog(@"requestString:%@",requestString);
56 | //如果是自己定义的协议, 再截取协议中的方法和参数, 判断无误后在这里手动调用oc方法
57 | NSMutableDictionary *param = [self queryStringToDictionary:requestString];
58 | NSLog(@"get param:%@",[param description]);
59 |
60 | NSString *func = [param objectForKey:@"func"];
61 |
62 | //调用本地函数1
63 | if([func isEqualToString:@"addSubView"])
64 | {
65 | Class tempClass = NSClassFromString([param objectForKey:@"view"]);
66 | CGRect frame = CGRectFromString([param objectForKey:@"frame"]);
67 |
68 | if(tempClass && [tempClass isSubclassOfClass:[UIWebView class]])
69 | {
70 | UIWebView *tempObj = [[tempClass alloc] initWithFrame:frame];
71 | tempObj.tag = [[param objectForKey:@"tag"] integerValue];
72 |
73 | NSURL *url = [NSURL URLWithString:[param objectForKey:@"urlstring"]];
74 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
75 | [tempObj loadRequest:request];
76 | [self.myWebView addSubview:tempObj];
77 | }
78 | }
79 | //调用本地函数2
80 | else if([func isEqualToString:@"alert"])
81 | {
82 | [self showMessage:@"来自网页的提示" message:[param objectForKey:@"message"]];
83 |
84 | }
85 | //调用本地函数3
86 | else if([func isEqualToString:@"callFunc"])
87 | {
88 | [self testFunc:[param objectForKey:@"first"] withParam2:[param objectForKey:@"second"] andParam3:[param objectForKey:@"third"] ];
89 |
90 | }
91 | //调用本地函数4
92 | else if([func isEqualToString:@"testFunc"])
93 | {
94 | [self testFunc:[param objectForKey:@"param1"] withParam2:[param objectForKey:@"param2"] andParam3:[param objectForKey:@"param3"] ];
95 |
96 | }
97 |
98 | return NO;
99 |
100 |
101 | }
102 | return YES;
103 | }
104 | -(void)testFunc:(NSString*)param1 withParam2:(NSString*)param2 andParam3:(NSString*)param3{
105 | NSLog(@"%@ %@ %@",param1,param2,param3);
106 | }
107 |
108 |
109 | -(void)loadHtml:(NSString*)name{
110 | NSString *filePath = [[NSBundle mainBundle]pathForResource:name ofType:@"html"];
111 |
112 | NSURL *url = [NSURL fileURLWithPath:filePath];
113 |
114 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
115 |
116 | [self.myWebView loadRequest:request];
117 | }
118 |
119 | -(void)showMessage:(NSString *)title message:(NSString *)message;
120 | {
121 | if (message == nil)
122 | {
123 | return;
124 | }
125 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
126 | message:message
127 | delegate:nil
128 | cancelButtonTitle:@"确定"
129 | otherButtonTitles:nil, nil];
130 | [alert show];
131 |
132 | }
133 | //get参数转字典
134 | - (NSMutableDictionary*)queryStringToDictionary:(NSString*)string {
135 | NSMutableArray *elements = (NSMutableArray*)[string componentsSeparatedByString:@"&"];
136 | [elements removeObjectAtIndex:0];
137 | NSMutableDictionary *retval = [NSMutableDictionary dictionaryWithCapacity:[elements count]];
138 | for(NSString *e in elements) {
139 | NSArray *pair = [e componentsSeparatedByString:@"="];
140 | [retval setObject:[pair objectAtIndex:1] forKey:[pair objectAtIndex:0]];
141 | }
142 | return retval;
143 | }
144 | @end
145 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/JSUIWebViewViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/UIWebViewJS.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
24 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
50 |
51 |
52 | 颗粒滤清器故障,柴油颗粒过滤器需要进行还原。
53 |
54 |
55 |
56 |
57 |
58 |
59 | 请以 4 档或 5 档(或 S档)、最低 60 km/h 的速度行驶大约 15 分钟,使发动机转速保持在大约 2000 转/ 分钟,直至指示灯熄灭。如果指示灯没有熄灭,请立即驶往维修站排除故障。确保您的车速与天气、道路、地形和交通状况相适应。不得由于行车建议而不遵守道路交通的法规。
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/UIWebViewJSViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // WebViewJS
4 | //
5 | // Created by jakey on 14-5-27.
6 | // Copyright (c) 2014年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIWebViewJSViewController : UIViewController
12 | @property (weak, nonatomic) IBOutlet UIWebView *myWeb;
13 |
14 | @property (strong, nonatomic) NSString *someString;
15 |
16 | - (IBAction)loadTouched:(id)sender;
17 | - (IBAction)exeFuncTouched:(id)sender;
18 | - (IBAction)insertHtmTouched:(id)sender;
19 | - (IBAction)inputButtonTouched:(id)sender;
20 | - (IBAction)insertJSTouched:(id)sender;
21 | - (IBAction)insertDivHtml:(id)sender;
22 | - (IBAction)submitTouched:(id)sender;
23 | - (IBAction)replaceImgSrc:(id)sender;
24 | - (IBAction)fontTouched:(id)sender;
25 | - (IBAction)locationTouched:(id)sender;
26 | - (IBAction)uploadTouched:(id)sender;
27 | @end
28 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/UIWebViewJSViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // WebViewJS
4 | //
5 | // Created by jakey on 14-5-27.
6 | // Copyright (c) 2014年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import "UIWebViewJSViewController.h"
10 | @interface UIWebViewJSViewController ()
11 |
12 | @end
13 |
14 | @implementation UIWebViewJSViewController
15 |
16 | - (void)viewDidLoad
17 | {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view, typically from a nib.
20 | self.title = @"UIWebView调用JS";
21 |
22 | self.view.backgroundColor = [UIColor grayColor];
23 | self.someString = @"UIWebView是iOS最常用的SDK之一,它有一个stringByEvaluatingJavaScriptFromString方法可以将javascript嵌入页面中,通过这个方法我们可以在iOS中与UIWebView中的网页元素交互";
24 |
25 |
26 | [self loadTouched:nil];
27 | }
28 |
29 | - (void)didReceiveMemoryWarning
30 | {
31 | [super didReceiveMemoryWarning];
32 | // Dispose of any resources that can be recreated.
33 | }
34 |
35 | - (IBAction)loadTouched:(id)sender {
36 | [self loadHtml:@"UIWebViewJS"];
37 | }
38 | //执行已经存在的js方法
39 | - (IBAction)exeFuncTouched:(id)sender {
40 | [self.myWeb stringByEvaluatingJavaScriptFromString:@"showAlert(\"hahahha\");"];
41 | }
42 |
43 | //插入html getElementsByTagName 根据html自带标签定位元素
44 | - (IBAction)insertHtmTouched:(id)sender {
45 | //插入整个页面内容
46 | // document.getElementsByTagName('body')[0];"
47 |
48 | //替换第一个P元素内容
49 | NSString *tempString = [NSString stringWithFormat:@"document.getElementsByTagName('p')[0].innerHTML ='%@';",self.someString];
50 | [self.myWeb stringByEvaluatingJavaScriptFromString:tempString];
51 |
52 | }
53 |
54 |
55 | // 插入html 根据getElementById 定位元素
56 | - (IBAction)insertDivHtml:(id)sender {
57 |
58 | //替换第id为idtest的DIV元素内容
59 | NSString *tempString2 = [NSString stringWithFormat:@"document.getElementById('idTest').innerHTML ='%@';",self.someString];
60 | [self.myWeb stringByEvaluatingJavaScriptFromString:tempString2];
61 |
62 | }
63 |
64 |
65 | //修改input值 getElementsByName根据标签名称获取定位元素
66 | - (IBAction)inputButtonTouched:(id)sender {
67 | NSString *tempString = [NSString stringWithFormat:@"document.getElementsByName('wd')[0].value='%@';",self.someString];
68 | [self.myWeb stringByEvaluatingJavaScriptFromString:tempString];
69 | }
70 |
71 | //插入js 并且执行传值
72 | - (IBAction)insertJSTouched:(id)sender {
73 | NSString *insertString = [NSString stringWithFormat:
74 | @"var script = document.createElement('script');"
75 | "script.type = 'text/javascript';"
76 | "script.text = \"function jsFunc() { "
77 | "var a=document.getElementsByTagName('body')[0];"
78 | "alert('%@');"
79 | "}\";"
80 | "document.getElementsByTagName('head')[0].appendChild(script);", self.someString];
81 |
82 | NSLog(@"insert string %@",insertString);
83 | [self.myWeb stringByEvaluatingJavaScriptFromString:insertString];
84 | [self.myWeb stringByEvaluatingJavaScriptFromString:@"jsFunc();"];
85 | }
86 |
87 | - (IBAction)submitTouched:(id)sender {
88 |
89 | [self.myWeb stringByEvaluatingJavaScriptFromString:@"document.forms[0].submit(); "];
90 | }
91 | //替换图片地址
92 | - (IBAction)replaceImgSrc:(id)sender {
93 | NSString *tempString2 = [NSString stringWithFormat:@"document.getElementsByTagName('img')[0].src ='%@';",@"light_advice.png"];
94 | [self.myWeb stringByEvaluatingJavaScriptFromString:tempString2];
95 | }
96 | //修改标签字体
97 | - (IBAction)fontTouched:(id)sender {
98 | NSString *tempString2 = [NSString stringWithFormat:@"document.getElementsByTagName('p')[0].style.fontSize='%@';",@"19px"];
99 | [self.myWeb stringByEvaluatingJavaScriptFromString:tempString2];
100 |
101 | }
102 | //定位
103 | - (IBAction)locationTouched:(id)sender {
104 | [self loadHtml:@"UIWebViewJS_location"];
105 | }
106 | //浏览文件
107 | - (IBAction)uploadTouched:(id)sender {
108 | [self loadHtml:@"UIWebViewJS_file"];
109 | }
110 | //传输json
111 | - (IBAction)jsonTouched:(id)sender {
112 | NSDictionary *dic = @{@"key":@"sdasd",@"ke2y":@"asd"};
113 |
114 | NSError *error = nil;
115 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic
116 | options:0
117 | error:&error];
118 |
119 | NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
120 |
121 | NSString *s = [NSString stringWithFormat:@"testJSON('%@');",jsonString];
122 |
123 | [self.myWeb stringByEvaluatingJavaScriptFromString:s];
124 |
125 | }
126 |
127 | -(void)loadHtml:(NSString*)name{
128 | NSString *filePath = [[NSBundle mainBundle]pathForResource:name ofType:@"html"];
129 |
130 | NSURL *url = [NSURL fileURLWithPath:filePath];
131 |
132 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
133 |
134 | [self.myWeb loadRequest:request];
135 | }
136 |
137 | @end
138 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/UIWebViewJSViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
34 |
45 |
56 |
67 |
78 |
89 |
100 |
111 |
122 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
154 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/UIWebViewJS_file.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/UIWebViewJS_location.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 点击这个按钮,获得您的坐标:
8 |
9 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/light_advice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/iOS-WebView-JavaScript/UIWebView/light_advice.png
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/UIWebView/light_illstration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaojiankui/iOS-WebView-JavaScript/b23c8a4835286ae2bae0cde07bfd0e8519d1a568/iOS-WebView-JavaScript/UIWebView/light_illstration.png
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/JSWKWebView.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/JSWKWebViewViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // JSWKWebViewViewController.h
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface JSWKWebViewViewController : UIViewController
13 | @property (strong, nonatomic) WKWebView *myWebView;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/JSWKWebViewViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // JSWKWebViewViewController.m
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import "JSWKWebViewViewController.h"
10 |
11 | @interface JSWKWebViewViewController ()
12 |
13 | @end
14 |
15 | @implementation JSWKWebViewViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | self.title = @"JS调用WKWebView";
20 | // Do any additional setup after loading the view from its nib.
21 |
22 | WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
23 | config.userContentController = [[WKUserContentController alloc] init];
24 | // 注入JS对象Native,
25 | // 声明WKScriptMessageHandler 协议
26 | [config.userContentController addScriptMessageHandler:self name:@"Native"];
27 | //本人喜欢只定义一个MessageHandler协议 当然可以定义其他MessageHandler协议
28 | [config.userContentController addScriptMessageHandler:self name:@"Pay"];
29 |
30 | self.myWebView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config];
31 | self.myWebView.UIDelegate = self;
32 | [self.view addSubview:self.myWebView];
33 | [self loadTouched:nil];
34 | }
35 |
36 | - (IBAction)loadTouched:(id)sender {
37 | [self loadHtml:@"JSWKWebView"];
38 | }
39 | #pragma mark - WKScriptMessageHandler
40 | - (void)userContentController:(WKUserContentController *)userContentController
41 | didReceiveScriptMessage:(WKScriptMessage *)message {
42 |
43 | NSDictionary *bodyParam = (NSDictionary*)message.body;
44 | NSString *func = [bodyParam objectForKey:@"function"];
45 |
46 | NSLog(@"MessageHandler Name:%@", message.name);
47 | NSLog(@"MessageHandler Body:%@", message.body);
48 | NSLog(@"MessageHandler Function:%@",func);
49 |
50 | //本人喜欢只定义一个MessageHandler协议 当然可以定义其他MessageHandler协议
51 |
52 | if ([message.name isEqualToString:@"Native"])
53 | {
54 | NSDictionary *parameters = [bodyParam objectForKey:@"parameters"];
55 | //调用本地函数1
56 | if([func isEqualToString:@"addSubView"])
57 | {
58 | Class tempClass = NSClassFromString([parameters objectForKey:@"view"]);
59 | CGRect frame = CGRectFromString([parameters objectForKey:@"frame"]);
60 |
61 | if(tempClass && [tempClass isSubclassOfClass:[UIWebView class]])
62 | {
63 | UIWebView *tempObj = [[tempClass alloc] initWithFrame:frame];
64 | tempObj.tag = [[parameters objectForKey:@"tag"] integerValue];
65 |
66 | NSURL *url = [NSURL URLWithString:[parameters objectForKey:@"urlstring"]];
67 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
68 | [tempObj loadRequest:request];
69 | [self.myWebView addSubview:tempObj];
70 | }
71 | }
72 | //调用本地函数2
73 | else if([func isEqualToString:@"alert"])
74 | {
75 | [self showMessage:@"来自网页的提示" message:[parameters description]];
76 |
77 | }
78 | //调用本地函数3
79 | else if([func isEqualToString:@"callFunc"])
80 | {
81 |
82 | }
83 | //调用本地函数4
84 | else if([func isEqualToString:@"testFunc"])
85 | {
86 |
87 |
88 | }
89 |
90 | }
91 | else if ([message.name isEqualToString:@"Pay"]) {
92 | //如果是自己定义的协议, 再截取协议中的方法和参数, 判断无误后在这里进行逻辑处理
93 |
94 | } else if ([message.name isEqualToString:@"dosomething"]) {
95 | //........
96 |
97 |
98 | }
99 |
100 | }
101 |
102 |
103 |
104 | -(void)loadHtml:(NSString*)name{
105 | NSString *filePath = [[NSBundle mainBundle]pathForResource:name ofType:@"html"];
106 |
107 | NSURL *url = [NSURL fileURLWithPath:filePath];
108 |
109 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
110 |
111 | [self.myWebView loadRequest:request];
112 | }
113 |
114 | -(void)showMessage:(NSString *)title message:(NSString *)message;
115 | {
116 | if (message == nil)
117 | {
118 | return;
119 | }
120 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
121 | message:[message description]
122 | delegate:nil
123 | cancelButtonTitle:@"确定"
124 | otherButtonTitles:nil, nil];
125 | [alert show];
126 |
127 | }
128 |
129 | #pragma mark - WKUIDelegate
130 | - (void)webViewDidClose:(WKWebView *)webView {
131 | NSLog(@"%s", __FUNCTION__);
132 | }
133 | //uiwebview 中这个方法是私有方法 通过category可以拦截alert
134 | - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler {
135 |
136 | NSLog(@"%s", __FUNCTION__);
137 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
138 | [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
139 | completionHandler();
140 | }]];
141 |
142 | [self presentViewController:alert animated:YES completion:NULL];
143 | }
144 |
145 |
146 |
147 | @end
148 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/JSWKWebViewViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/WKWebViewJS.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
40 |
41 |
42 |
43 |
44 |
45 | 颗粒滤清器故障,柴油颗粒过滤器需要进行还原。
46 |
47 |
48 |
49 |
50 |
51 |
52 | 请以 4 档或 5 档(或 S档)、最低 60 km/h 的速度行驶大约 15 分钟,使发动机转速保持在大约 2000 转/ 分钟,直至指示灯熄灭。如果指示灯没有熄灭,请立即驶往维修站排除故障。确保您的车速与天气、道路、地形和交通状况相适应。不得由于行车建议而不遵守道路交通的法规。
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/WKWebViewJSViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebViewViewController.h
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | @interface WKWebViewJSViewController : UIViewController
12 | @property (strong, nonatomic) WKWebView *myWebView;
13 |
14 | @property (strong, nonatomic) NSString *someString;
15 |
16 | - (IBAction)loadTouched:(id)sender;
17 | - (IBAction)exeFuncTouched:(id)sender;
18 | - (IBAction)insertHtmTouched:(id)sender;
19 | - (IBAction)inputButtonTouched:(id)sender;
20 | - (IBAction)insertJSTouched:(id)sender;
21 | - (IBAction)insertDivHtml:(id)sender;
22 | - (IBAction)submitTouched:(id)sender;
23 | - (IBAction)replaceImgSrc:(id)sender;
24 | - (IBAction)fontTouched:(id)sender;
25 | - (IBAction)locationTouched:(id)sender;
26 | - (IBAction)uploadTouched:(id)sender;
27 | @end
28 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/WKWebViewJSViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // WKWebViewViewController.m
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 16/4/10.
6 | // Copyright © 2016年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import "WKWebViewJSViewController.h"
10 |
11 | @interface WKWebViewJSViewController ()
12 |
13 | @end
14 |
15 | @implementation WKWebViewJSViewController
16 |
17 | - (void)viewDidLoad
18 | {
19 | [super viewDidLoad];
20 | // Do any additional setup after loading the view, typically from a nib.
21 | self.title = @"WKWebView调用JS";
22 |
23 | self.myWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 221) configuration:[[WKWebViewConfiguration alloc] init]];
24 | self.myWebView.UIDelegate = self;
25 | [self.view addSubview:self.myWebView];
26 |
27 | self.view.backgroundColor = [UIColor grayColor];
28 | self.someString = @"iOS 8引入了一个新的框架——WebKit,之后变得好起来了。在WebKit框架中,有WKWebView可以替换UIKit的UIWebView和AppKit的WebView,而且提供了在两个平台可以一致使用的接口。WebKit框架使得开发者可以在原生App中使用Nitro来提高网页的性能和表现,Nitro就是Safari的JavaScript引擎 WKWebView 不支持JavaScriptCore的方式但提供message handler的方式为JavaScript与Native通信";
29 | // self.myWebView.UIDelegate = self;
30 |
31 | [self loadTouched:nil];
32 | }
33 |
34 | - (void)didReceiveMemoryWarning
35 | {
36 | [super didReceiveMemoryWarning];
37 | // Dispose of any resources that can be recreated.
38 | }
39 |
40 | - (IBAction)loadTouched:(id)sender {
41 | [self loadHtml:@"WKWebViewJS"];
42 | }
43 |
44 |
45 | //执行已经存在的js方法
46 | - (IBAction)exeFuncTouched:(id)sender {
47 | [self.myWebView evaluateJavaScript:@"showAlert('hahahha')" completionHandler:^(id item, NSError * _Nullable error) {
48 |
49 | }];
50 | }
51 |
52 | //插入html getElementsByTagName 根据html自带标签定位元素
53 | - (IBAction)insertHtmTouched:(id)sender {
54 | //插入整个页面内容
55 | // document.getElementsByTagName('body')[0];"
56 |
57 | //替换第一个P元素内容
58 | NSString *tempString = [NSString stringWithFormat:@"document.getElementsByTagName('p')[0].innerHTML ='%@';",self.someString];
59 | [self.myWebView evaluateJavaScript:tempString completionHandler:^(id item, NSError * _Nullable error) {
60 |
61 | }];
62 | }
63 |
64 |
65 | // 插入html 根据getElementById 定位元素
66 | - (IBAction)insertDivHtml:(id)sender {
67 |
68 | //替换第id为idtest的DIV元素内容
69 | NSString *tempString2 = [NSString stringWithFormat:@"document.getElementById('idTest').innerHTML ='%@';",self.someString];
70 | [self.myWebView evaluateJavaScript:tempString2 completionHandler:^(id item, NSError * _Nullable error) {
71 |
72 | }];
73 | }
74 |
75 |
76 | //修改input值 getElementsByName根据标签名称获取定位元素
77 | - (IBAction)inputButtonTouched:(id)sender {
78 | NSString *tempString = [NSString stringWithFormat:@"document.getElementsByName('wd')[0].value='%@';",self.someString];
79 | [self.myWebView evaluateJavaScript:tempString completionHandler:^(id item, NSError * _Nullable error) {
80 |
81 | }];
82 | }
83 |
84 | //插入js 并且执行传值
85 | - (IBAction)insertJSTouched:(id)sender {
86 | NSString *insertString = [NSString stringWithFormat:
87 | @"var script = document.createElement('script');"
88 | "script.type = 'text/javascript';"
89 | "script.text = \"function jsFunc() { "
90 | "var a=document.getElementsByTagName('body')[0];"
91 | "alert('%@');"
92 | "}\";"
93 | "document.getElementsByTagName('head')[0].appendChild(script);", self.someString];
94 |
95 | NSLog(@"insert string %@",insertString);
96 | [self.myWebView evaluateJavaScript:insertString completionHandler:^(id item, NSError * _Nullable error) {
97 |
98 | }];
99 |
100 | [self.myWebView evaluateJavaScript:@"jsFunc();" completionHandler:^(id item, NSError * _Nullable error) {
101 |
102 | }];
103 | }
104 |
105 | - (IBAction)submitTouched:(id)sender {
106 | [self.myWebView evaluateJavaScript:@"document.forms[0].submit(); " completionHandler:^(id item, NSError * _Nullable error) {
107 |
108 | }];
109 | }
110 | //替换图片地址
111 | - (IBAction)replaceImgSrc:(id)sender {
112 | NSString *tempString2 = [NSString stringWithFormat:@"document.getElementsByTagName('img')[0].src ='%@';",@"light_advice.png"];
113 | [self.myWebView evaluateJavaScript:tempString2 completionHandler:^(id item, NSError * _Nullable error) {
114 |
115 | }];
116 | }
117 | //修改标签字体
118 | - (IBAction)fontTouched:(id)sender {
119 | NSString *tempString2 = [NSString stringWithFormat:@"document.getElementsByTagName('p')[0].style.fontSize='%@';",@"19px"];
120 | [self.myWebView evaluateJavaScript:tempString2 completionHandler:^(id item, NSError * _Nullable error) {
121 |
122 | }];
123 |
124 | }
125 | //定位
126 | - (IBAction)locationTouched:(id)sender {
127 | [self loadHtml:@"UIWebViewJS_location"];
128 | }
129 | //浏览文件
130 | - (IBAction)uploadTouched:(id)sender {
131 | [self loadHtml:@"UIWebViewJS_file"];
132 | }
133 |
134 | -(void)loadHtml:(NSString*)name{
135 | NSString *filePath = [[NSBundle mainBundle]pathForResource:name ofType:@"html"];
136 |
137 | NSURL *url = [NSURL fileURLWithPath:filePath];
138 |
139 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
140 |
141 | [self.myWebView loadRequest:request];
142 | }
143 | #pragma mark - WKUIDelegate
144 | - (void)webViewDidClose:(WKWebView *)webView {
145 | NSLog(@"%s", __FUNCTION__);
146 | }
147 | //uiwebview 中这个方法是私有方法 通过category可以拦截alert
148 | - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler {
149 |
150 | NSLog(@"%s", __FUNCTION__);
151 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
152 | [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
153 | completionHandler();
154 | }]];
155 |
156 | [self presentViewController:alert animated:YES completion:NULL];
157 | }
158 |
159 | @end
160 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/WKWebViewJSViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
28 |
38 |
48 |
58 |
68 |
78 |
88 |
98 |
108 |
118 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/WKWebViewJS_file.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/WKWebView/WKWebViewJS_location.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 点击这个按钮,获得您的坐标:
7 |
8 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/iOS-WebView-JavaScript-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | or.skyfox.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | Launch Screen
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | NSAppTransportSecurity
40 |
41 | NSAllowsArbitraryLoads
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/iOS-WebView-JavaScript-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_3_0
10 | #warning "This project uses features only available in iOS SDK 3.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/iOS-WebView-JavaScript/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // WebViewJS
4 | //
5 | // Created by Jakey on 14-7-23.
6 | // Copyright (c) 2014年 www.skyfox.org All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------