Created
March 20, 2014 16:31
-
-
Save alloy/9667982 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a147862c9fcfe0cf57f1e664ce4ea1dd263f4af2 Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= <eloy.de.enige@gmail.com> | |
Date: Thu, 20 Mar 2014 17:27:49 +0100 | |
Subject: [PATCH] Work around RubyMotion bug by (un)boxing args in objc. | |
Related to http://hipbyte.myjetbrains.com/youtrack/issue/RM-448. | |
--- | |
rubymotion/BaseTableViewCell/BaseTableViewCell.h | 5 +++++ | |
rubymotion/BaseTableViewCell/BaseTableViewCell.m | 17 +++++++++++++++++ | |
rubymotion/Rakefile | 1 + | |
rubymotion/app/views/scroll_cell.rb | 14 +++++++++++--- | |
4 files changed, 34 insertions(+), 3 deletions(-) | |
create mode 100644 rubymotion/BaseTableViewCell/BaseTableViewCell.h | |
create mode 100644 rubymotion/BaseTableViewCell/BaseTableViewCell.m | |
diff --git a/rubymotion/BaseTableViewCell/BaseTableViewCell.h b/rubymotion/BaseTableViewCell/BaseTableViewCell.h | |
new file mode 100644 | |
index 0000000..28d51f0 | |
--- /dev/null | |
+++ b/rubymotion/BaseTableViewCell/BaseTableViewCell.h | |
@@ -0,0 +1,5 @@ | |
+#import <UIKit/UIKit.h> | |
+ | |
+@interface BaseTableViewCell : UITableViewCell <UIScrollViewDelegate> | |
+@end | |
+ | |
diff --git a/rubymotion/BaseTableViewCell/BaseTableViewCell.m b/rubymotion/BaseTableViewCell/BaseTableViewCell.m | |
new file mode 100644 | |
index 0000000..0e14c66 | |
--- /dev/null | |
+++ b/rubymotion/BaseTableViewCell/BaseTableViewCell.m | |
@@ -0,0 +1,17 @@ | |
+#import "BaseTableViewCell.h" | |
+ | |
+@implementation BaseTableViewCell | |
+ | |
+- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView | |
+ withVelocity:(CGPoint)velocity | |
+ targetContentOffset:(inout CGPoint *)originalOffset | |
+{ | |
+ SEL sel = @selector(scrollViewWillEndDraggingWithVelocity:targetContentOffset:); | |
+ NSValue *offsetValue = [self performSelector:sel | |
+ withObject:[NSValue valueWithCGPoint:velocity] | |
+ withObject:[NSValue valueWithCGPoint:*originalOffset]]; | |
+ CGPoint offset = [offsetValue CGPointValue]; | |
+ *originalOffset = offset; | |
+} | |
+ | |
+@end | |
diff --git a/rubymotion/Rakefile b/rubymotion/Rakefile | |
index e654a9e..96885ce 100644 | |
--- a/rubymotion/Rakefile | |
+++ b/rubymotion/Rakefile | |
@@ -11,4 +11,5 @@ end | |
Motion::Project::App.setup do |app| | |
# Use `rake config' to see complete project settings. | |
app.name = 'scroll-test' | |
+ app.vendor_project 'BaseTableViewCell', :static | |
end | |
diff --git a/rubymotion/app/views/scroll_cell.rb b/rubymotion/app/views/scroll_cell.rb | |
index d9db7f3..68f6b1f 100644 | |
--- a/rubymotion/app/views/scroll_cell.rb | |
+++ b/rubymotion/app/views/scroll_cell.rb | |
@@ -1,4 +1,4 @@ | |
-class ScrollCell < UITableViewCell | |
+class ScrollCell < BaseTableViewCell | |
def initWithStyle(style, reuseIdentifier: reuse_identifier) | |
super.tap do |cell| | |
cell.selectionStyle = UITableViewCellSelectionStyleNone | |
@@ -18,7 +18,15 @@ class ScrollCell < UITableViewCell | |
@scroll_view.contentSize = [contentView.frame.size.width * 2, contentView.frame.size.height] | |
end | |
- def scrollViewWillEndDragging(scroll_view, withVelocity: velocity, targetContentOffset: target_content_offset) | |
- p 'scrollViewWillEndDragging' | |
+ RevealWidth = 1 | |
+ | |
+ def scrollViewWillEndDraggingWithVelocity(velocityValue, targetContentOffset:offsetValue) | |
+ offset = offsetValue.CGPointValue | |
+ if velocityValue.CGPointValue.x > 0 | |
+ offset.x = RevealWidth | |
+ else | |
+ offset.x = 0 | |
+ end | |
+ NSValue.valueWithCGPoint(offset) | |
end | |
end | |
-- | |
1.8.5.2 (Apple Git-48) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment