|
1 | 1 | # JsBridge-WebViewJavascriptBridge
|
2 | 2 | iOS JsBridge Solution by WebViewJavascriptBridge
|
3 | 3 |
|
| 4 | +为 [JsBridge](https://github.com/pengwei1024/JsBridge) 开发的 iOS 解决方案 |
| 5 | + |
4 | 6 | 
|
5 | 7 |
|
| 8 | +## Sample |
| 9 | +**Native register** |
| 10 | + |
| 11 | +``` |
| 12 | +[self.bridge registerHandler:@"MyBridge.native.alertDialog" handler:^(id data, WVJBResponseCallback responseCallback) { |
| 13 | +
|
| 14 | + if (data && [data isKindOfClass:[NSDictionary class]]) { |
| 15 | + NSLog(@"title = %@, desc=%@", [data objectForKey:@"title"], [data objectForKey:@"desc"]); |
| 16 | + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[data objectForKey:@"title"] |
| 17 | + message:[data objectForKey:@"desc"] |
| 18 | + delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"sure", nil]; |
| 19 | + [alertView show]; |
| 20 | + callback = responseCallback; |
| 21 | + } |
| 22 | + }]; |
| 23 | +``` |
| 24 | +**Js Call** |
| 25 | + |
| 26 | +``` |
| 27 | +MyBridge.native.alertDialog( |
| 28 | + 'Title', |
| 29 | + 'it\'s a native dialog', |
| 30 | + function(){ |
| 31 | + alert('sure button click'); |
| 32 | + }, |
| 33 | + function(){ |
| 34 | + alert('cancel button click'); |
| 35 | + } |
| 36 | + ); |
| 37 | +``` |
| 38 | + |
| 39 | +## License |
| 40 | +<pre> |
| 41 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 42 | +you may not use this file except in compliance with the License. |
| 43 | +You may obtain a copy of the License at |
| 44 | + |
| 45 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 46 | + |
| 47 | +Unless required by applicable law or agreed to in writing, software |
| 48 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 49 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 50 | +See the License for the specific language governing permissions and |
| 51 | +limitations under the License. |
| 52 | +</pre> |
| 53 | + |
0 commit comments