Skip to content

Commit

Permalink
fix 部分工程error。
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghualei committed Dec 18, 2018
1 parent 41d0dcc commit bf1efa7
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 35 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JS_OC_Cordova.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JS_OC_JavaScriptCore.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
16 changes: 12 additions & 4 deletions JS_OC_JavaScriptCore/JS_OC_JavaScriptCore/WebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ - (void)addSetBGColorWithContext:(JSContext *)context
CGFloat g = [[args[1] toNumber] floatValue];
CGFloat b = [[args[2] toNumber] floatValue];
CGFloat a = [[args[3] toNumber] floatValue];

weakSelf.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];

// 注意 现在执行JS是在WebThread的子线程(以前是在主线程),操作UI需要回到主线程。
dispatch_async(dispatch_get_main_queue(), ^{
// 这里是操作UI的操作
weakSelf.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
});
};
}

Expand Down Expand Up @@ -150,15 +154,19 @@ - (void)addShakeActionWithContext:(JSContext *)context
{

context[@"shake"] = ^() {
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
dispatch_async(dispatch_get_main_queue(), ^{
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
});
};
}

- (void)addGoBackWithContext:(JSContext *)context
{
__weak typeof(self) weakSelf = self;
context[@"goBack"] = ^() {
[weakSelf.webView goBack];
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.webView goBack];
});
};
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JS_OC_MessageHandler.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JS_OC_URL.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
25 changes: 14 additions & 11 deletions JS_OC_URL/JS_OC_URL/MainViewController.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<deployment version="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MainViewController">
Expand All @@ -12,33 +16,32 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gAc-HV-C57">
<rect key="frame" x="90" y="169" width="141" height="30"/>
<button opaque="NO" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gAc-HV-C57">
<rect key="frame" x="116.5" y="169" width="142" height="30"/>
<state key="normal" title="UIWebView 拦截URL"/>
<connections>
<action selector="btnClick1:" destination="-1" eventType="touchUpInside" id="wgl-EI-F7U"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5ad-vQ-Hfm">
<rect key="frame" x="85" y="248" width="150" height="30"/>
<rect key="frame" x="112" y="248" width="151" height="30"/>
<state key="normal" title="WKWebView 拦截URL"/>
<connections>
<action selector="btnClick2:" destination="-1" eventType="touchUpInside" id="JQc-Bz-S6l"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="gAc-HV-C57" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="1ts-Sy-f9K"/>
<constraint firstItem="gAc-HV-C57" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="169" id="4SR-Cn-IUQ"/>
<constraint firstItem="5ad-vQ-Hfm" firstAttribute="top" secondItem="gAc-HV-C57" secondAttribute="bottom" constant="49" id="hy6-AA-i0s"/>
<constraint firstItem="5ad-vQ-Hfm" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="rr0-L2-lff"/>
</constraints>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<point key="canvasLocation" x="247" y="393"/>
<point key="canvasLocation" x="-39.200000000000003" y="39.130434782608695"/>
</view>
</objects>
</document>
2 changes: 1 addition & 1 deletion JS_OC_URL/JS_OC_URL/WKWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ - (void)payAction:(NSURL *)URL
// 支付操作

// 将支付结果返回给js
NSString *jsStr = [NSString stringWithFormat:@"payResult('%@')",@"支付成功"];
NSString *jsStr = [NSString stringWithFormat:@"payResult('%@', 1)",@"支付成功"];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"%@----%@",result, error);
}];
Expand Down
1 change: 1 addition & 0 deletions JS_OC_URL/JS_OC_URL/WebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ - (void)changeBGColor:(NSURL *)URL
CGFloat b = [[tempDic objectForKey:@"b"] floatValue];
CGFloat a = [[tempDic objectForKey:@"a"] floatValue];

// 这里修改背景色是因为有些场景没有导航栏,然后WebView 是从 状态栏下20开始布局,用于修改状态栏背景色
self.view.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a];
}

Expand Down
4 changes: 2 additions & 2 deletions JS_OC_URL/JS_OC_URL/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
iFrame = null;
}
function scanClick() {
alert(arr);
asyncAlert(arr);
loadURL("haleyAction://scanClick");
}

Expand Down Expand Up @@ -119,4 +119,4 @@ <h4>竖直方向的表头:</h4>


</body>
</html>
</html>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JS_OC.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
48 changes: 33 additions & 15 deletions JS_OC_summary/JS_OC/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ham-Sw-iUw">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="ham-Sw-iUw">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Tab Bar Controller-->
Expand All @@ -14,7 +18,7 @@
<tabBar key="tabBar" contentMode="scaleToFill" id="aQI-ov-QdM">
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</tabBar>
<connections>
<segue destination="Di6-Jb-F3w" kind="relationship" relationship="viewControllers" id="vAO-8e-2uh"/>
Expand All @@ -23,7 +27,7 @@
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yuI-WX-dWn" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-848" y="111"/>
<point key="canvasLocation" x="-1274" y="112"/>
</scene>
<!--方式一-->
<scene sceneID="PzU-kF-ldM">
Expand All @@ -33,7 +37,7 @@
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="568"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="VJ3-Lu-pyj">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -56,12 +60,18 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kVx-2M-QtT">
<webView contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kVx-2M-QtT">
<rect key="frame" x="0.0" y="64" width="320" height="455"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="deviceRGB"/>
<color key="backgroundColor" red="0.28958413004875183" green="0.31462949514389038" blue="0.32950475811958313" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</webView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="FOE-2r-GOO" firstAttribute="top" secondItem="kVx-2M-QtT" secondAttribute="bottom" id="7dA-KP-Cyd"/>
<constraint firstItem="kVx-2M-QtT" firstAttribute="top" secondItem="hJW-bw-xjO" secondAttribute="bottom" id="90E-hi-ytd"/>
<constraint firstAttribute="trailing" secondItem="kVx-2M-QtT" secondAttribute="trailing" id="GpK-Op-0iL"/>
<constraint firstItem="kVx-2M-QtT" firstAttribute="leading" secondItem="lzq-8A-fmv" secondAttribute="leading" id="cD8-qT-e30"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="方式一" id="c3E-en-XfT"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
Expand All @@ -82,7 +92,7 @@
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="568"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="jRm-aL-1mx">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -102,17 +112,25 @@
<viewControllerLayoutGuide type="bottom" id="QJI-bf-OTg"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Iop-7V-qWX">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="455"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bQB-YT-Ouq">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="deviceRGB"/>
<webView contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bQB-YT-Ouq">
<rect key="frame" x="0.0" y="0.0" width="320" height="455"/>
<color key="backgroundColor" red="0.28958413004875183" green="0.31462949514389038" blue="0.32950475811958313" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</webView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="bQB-YT-Ouq" secondAttribute="trailing" id="6br-Xz-oRe"/>
<constraint firstItem="bQB-YT-Ouq" firstAttribute="top" secondItem="cPh-aP-GAc" secondAttribute="bottom" id="PIV-8W-2g6"/>
<constraint firstAttribute="bottom" secondItem="bQB-YT-Ouq" secondAttribute="bottom" id="XBD-mb-msS"/>
<constraint firstItem="bQB-YT-Ouq" firstAttribute="leading" secondItem="Iop-7V-qWX" secondAttribute="leading" id="cy6-SS-AOF"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="方式二" id="kAq-0h-pLk"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics" translucent="NO"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="568"/>
<connections>
Expand Down
6 changes: 4 additions & 2 deletions JS_OC_summary/JS_OC/SeondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ - (void)viewDidLoad {
NSLog(@"+++++++Begin Log+++++++");
NSArray *args = [JSContext currentArguments];

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"方式二" message:@"这是OC原生的弹出窗" delegate:self cancelButtonTitle:@"收到" otherButtonTitles:nil];
[alertView show];
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"方式二" message:@"这是OC原生的弹出窗" delegate:self cancelButtonTitle:@"收到" otherButtonTitles:nil];
[alertView show];
});

for (JSValue *jsVal in args) {
NSLog(@"%@", jsVal.toString);
Expand Down

0 comments on commit bf1efa7

Please sign in to comment.