Skip to content

Commit e3bf3e2

Browse files
Merge pull request #13 from kishikawakatsumi/gesture
Fix UIGestureRecognizer header.
2 parents d8dc028 + 39e6012 commit e3bf3e2

File tree

7 files changed

+103
-7
lines changed

7 files changed

+103
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# JavaScriptBridge CHANGELOG
22

3+
## 0.1.3
4+
- Add support UIBarButtonItem's `init` mathod.
5+
36
## 0.1.2
47
- Fix not to assign `self` object on calling some UITableView delegate methods on 64 bit devices.
58

Classes/iOS/FrameworkSupport/UIKit/JSBUIGestureRecognizer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1212

1313
@property (nonatomic, readwrite) UIGestureRecognizerState state;
14+
@property(nonatomic, assign) id <UIGestureRecognizerDelegate> delegate;
15+
@property(nonatomic, getter = isEnabled) BOOL enabled;
16+
@property(nonatomic, readonly) UIView *view;
17+
@property(nonatomic) BOOL cancelsTouchesInView;
18+
@property(nonatomic) BOOL delaysTouchesBegan;
19+
@property(nonatomic) BOOL delaysTouchesEnded;
1420

1521
- (void)ignoreTouch:(UITouch *)touch forEvent:(UIEvent *)event;
1622
- (void)reset;

Examples/UICatalog/UICatalog.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
149C56851875C5BB0003EE16 /* JSBTwitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 149C55DA1875C5BB0003EE16 /* JSBTwitter.m */; };
5454
149C56861875C5BB0003EE16 /* JSBUIKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 149C56171875C5BB0003EE16 /* JSBUIKit.m */; };
5555
149C56871875C5BB0003EE16 /* JSBiAd.m in Sources */ = {isa = PBXBuildFile; fileRef = 149C56681875C5BB0003EE16 /* JSBiAd.m */; };
56+
149ED65218A1483D0078236E /* gestureViewController.js in Resources */ = {isa = PBXBuildFile; fileRef = 149ED65018A148230078236E /* gestureViewController.js */; };
5657
14A045081877E7E3004831E8 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 14A044FF1877E7B1004831E8 /* main.js */; };
5758
14A045091877E7E3004831E8 /* mainViewController.js in Resources */ = {isa = PBXBuildFile; fileRef = 14A045001877E7B1004831E8 /* mainViewController.js */; };
5859
14A0450A1877E7E3004831E8 /* buttonsViewController.js in Resources */ = {isa = PBXBuildFile; fileRef = 14A044FD1877E7B1004831E8 /* buttonsViewController.js */; };
@@ -775,6 +776,7 @@
775776
149C56661875C5BB0003EE16 /* JSBMPMoviePlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBMPMoviePlayerController.h; sourceTree = "<group>"; };
776777
149C56671875C5BB0003EE16 /* JSBiAd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBiAd.h; sourceTree = "<group>"; };
777778
149C56681875C5BB0003EE16 /* JSBiAd.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSBiAd.m; sourceTree = "<group>"; };
779+
149ED65018A148230078236E /* gestureViewController.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = gestureViewController.js; path = js/gestureViewController.js; sourceTree = "<group>"; };
778780
14A044FD1877E7B1004831E8 /* buttonsViewController.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = buttonsViewController.js; path = js/buttonsViewController.js; sourceTree = "<group>"; };
779781
14A044FE1877E7B1004831E8 /* controlsViewController.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = controlsViewController.js; path = js/controlsViewController.js; sourceTree = "<group>"; };
780782
14A044FF1877E7B1004831E8 /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = js/main.js; sourceTree = "<group>"; };
@@ -1779,6 +1781,7 @@
17791781
14D6C30B18793F12005C7018 /* collectionViewController.js */,
17801782
14A045011877E7B1004831E8 /* webViewController.js */,
17811783
14A0450D1877E870004831E8 /* mapViewController.js */,
1784+
149ED65018A148230078236E /* gestureViewController.js */,
17821785
);
17831786
name = js;
17841787
sourceTree = "<group>";
@@ -1932,6 +1935,7 @@
19321935
14D6C30C18793F12005C7018 /* collectionViewController.js in Resources */,
19331936
14A0450C1877E7E3004831E8 /* webViewController.js in Resources */,
19341937
14A0450E1877E870004831E8 /* mapViewController.js in Resources */,
1938+
149ED65218A1483D0078236E /* gestureViewController.js in Resources */,
19351939
14B5CD2A1875C3740019A135 /* InfoPlist.strings in Resources */,
19361940
14B5CD321875C3740019A135 /* Images.xcassets in Resources */,
19371941
);
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
var GestureViewController = JSB.defineClass('GestureViewController : UIViewController', {
2+
viewDidLoad: function() {
3+
self.navigationItem.title = 'Gesture';
4+
5+
var swipeView = UIView.alloc().initWithFrame({x: 10, y: 300, width: 300, height: 120});
6+
swipeView.backgroundColor = UIColor.greenColor();
7+
8+
var swipeLabel = UILabel.alloc().initWithFrame(swipeView.bounds);
9+
swipeLabel.text = 'Swipe';
10+
swipeLabel.textAlignment = 1;
11+
swipeLabel.textColor = UIColor.whiteColor();
12+
swipeView.addSubview(swipeLabel);
13+
14+
self.view.addSubview(swipeView);
15+
16+
var swipeGestureRecognizer = UISwipeGestureRecognizer.alloc().initWithTargetAction(self, 'handleSwipe:');
17+
swipeGestureRecognizer.direction = 1 << 0 | 1 << 1;
18+
swipeView.addGestureRecognizer(swipeGestureRecognizer);
19+
20+
var tapView = UIView.alloc().initWithFrame({x: 80, y: 100, width: 80, height: 80});
21+
tapView.backgroundColor = UIColor.redColor();
22+
23+
var tapLabel = UILabel.alloc().initWithFrame(tapView.bounds);
24+
tapLabel.text = 'Tap';
25+
tapLabel.textAlignment = 1;
26+
tapLabel.textColor = UIColor.whiteColor();
27+
tapView.addSubview(tapLabel);
28+
29+
self.view.addSubview(tapView);
30+
31+
var tapGestureRecognizer = UITapGestureRecognizer.alloc().initWithTargetAction(self, 'handleTap:');
32+
tapView.addGestureRecognizer(tapGestureRecognizer);
33+
34+
var panView = UIView.alloc().initWithFrame({x: 180, y: 200, width: 80, height: 80});
35+
panView.backgroundColor = UIColor.blueColor();
36+
37+
var panLabel = UILabel.alloc().initWithFrame(panView.bounds);
38+
panLabel.text = 'Pan';
39+
panLabel.textAlignment = 1;
40+
panLabel.textColor = UIColor.whiteColor();
41+
panView.addSubview(panLabel);
42+
43+
self.view.addSubview(panView);
44+
45+
var panGestureRecognizer = UIPanGestureRecognizer.alloc().initWithTargetAction(self, 'handlePan:');
46+
panView.addGestureRecognizer(panGestureRecognizer);
47+
},
48+
handleTap: function(sender) {
49+
var alertView = UIAlertView.new();
50+
alertView.message = 'Tapped.';
51+
alertView.addButtonWithTitle('OK');
52+
alertView.show();
53+
},
54+
handlePan: function(sender) {
55+
var point = sender.translationInView(sender.view);
56+
var center = sender.view.center;
57+
sender.view.center = {x: center.x + point.x, y: center.y + point.y};
58+
59+
sender.setTranslationInView({x: 0, y: 0}, sender.view);
60+
},
61+
handleSwipe: function(sender) {
62+
var label = UILabel.alloc().initWithFrame({x: 0, y: 0, width: 180, height: 60});
63+
label.backgroundColor = UIColor.colorWithWhiteAlpha(0.0, 0.5);
64+
label.center = self.view.center;
65+
label.alpha = 0.0;
66+
label.text = 'Swiped';
67+
label.textAlignment = 1;
68+
label.textColor = UIColor.whiteColor();
69+
self.view.addSubview(label);
70+
71+
UIView.animateWithDurationDelayOptionsAnimationsCompletion(0.3, 0.0, 0 << 16, function() {
72+
label.alpha = 1.0;
73+
}, function(finished) {
74+
UIView.animateWithDurationDelayOptionsAnimationsCompletion(0.3, 0.5, 0 << 16, function() {
75+
label.alpha = 0.0;
76+
}, function(finished) {
77+
label.removeFromSuperView();
78+
});
79+
});
80+
}
81+
});
82+
83+
JSB.exports = GestureViewController;

Examples/UICatalog/UICatalog/js/mainViewController.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var TwitterViewController = JSB.require('twitterViewController');
44
var CollectionViewController = JSB.require('collectionViewController');
55
var WebViewController = JSB.require('webViewController');
66
var MapViewController = JSB.require('mapViewController');
7+
var GestureViewController = JSB.require('gestureViewController');
78

89
var MainViewController = JSB.defineClass('MainViewController : UITableViewController', {
910
viewDidLoad: function() {
@@ -38,6 +39,11 @@ var MainViewController = JSB.defineClass('MainViewController : UITableViewContro
3839
title: 'Map',
3940
explanation: 'Use of MKMapView',
4041
viewController: MapViewController.alloc().init()
42+
},
43+
{
44+
title: 'Gesture',
45+
explanation: 'Use of UIGestureRecognizer',
46+
viewController: GestureViewController.alloc().init()
4147
}]
4248
},
4349
tableViewNumberOfRowsInSection: function(tableView, section) {

Examples/UICatalog/UICatalog/js/mapViewController.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ var MapViewController = JSB.defineClass('MapViewController : UIViewController <M
1919
},
2020
viewWillDisappear: function(animated) {
2121
self.mapView.delegate = null;
22-
},
23-
webViewDidStartLoad: function(webView) {
24-
UIApplication.sharedApplication().networkActivityIndicatorVisible = true;
25-
},
26-
webViewDidFinishLoad: function(webView) {
27-
UIApplication.sharedApplication().networkActivityIndicatorVisible = false;
2822
}
2923
});
3024

JavaScriptBridge.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "JavaScriptBridge"
3-
s.version = "0.1.2"
3+
s.version = "0.1.3"
44
s.summary = "Write iOS apps in Javascript! JavaScriptBridge provides the way to write iOS apps with JavaScript."
55
s.homepage = "https://github.com/kishikawakatsumi/JavaScriptBridge"
66
s.social_media_url = "https://twitter.com/k_katsumi"

0 commit comments

Comments
 (0)