This file contains hidden or 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
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { | |
if (scrollView.contentOffset.x < -scrollView.contentInset.left) { | |
targetContentOffset->x = -scrollView.contentInset.left; | |
} else { | |
*targetContentOffset = CGPointZero; | |
} | |
} |
This file contains hidden or 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
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
// This is necessary to ensure that the content size scales with the view. | |
self.scrollView.contentSize = self.contentView.bounds.size; | |
self.scrollView.contentOffset = CGPointZero; | |
} |
This file contains hidden or 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
2015-01-26 22:19:55.120 SwipeableTableViewCell[21735:2347995] setFrame | |
frame={{0, 0}, {320, 44}} | |
self.bounds={{0, 0}, {320, 44}} | |
self.frame={{0, 0}, {320, 44}} | |
self.contentView.bounds={{0, 0}, {0, 0}} | |
self.scrollView.bounds={{0, 0}, {0, 0}} | |
self.scrollView.frame={{0, 0}, {0, 0}} | |
self.scrollView.contentOffset={0, 0} | |
2015-01-26 22:19:55.121 SwipeableTableViewCell[21735:2347995] setFrame |
This file contains hidden or 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
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
if (scrollView.contentOffset.x > 0) { | |
scrollView.contentOffset = CGPointZero; | |
} | |
} |
This file contains hidden or 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
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
if (scrollView.contentOffset.x > 0) { | |
scrollView.contentOffset = CGPointZero; | |
} | |
self.buttonsView.frame = CGRectMake(scrollView.contentOffset.x, 0, 160, self.buttonsView.frame.size.height); | |
} |
This file contains hidden or 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
@interface AlertViewCallback : NSObject <UIAlertViewDelegate> | |
@property (copy, nonatomic) void (^callback)(void); | |
@end | |
@implementation AlertViewCallback | |
+ (instancetype)callback:(void (^)(void))callback { | |
return [[self alloc] initWithCallback:callback]; | |
} |
This file contains hidden or 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
- (void)alertWithTitle:(NSString *)title | |
message:(NSString *)message | |
close:(NSString *)closeText | |
action:(NSString *)actionText | |
then:(void (^)(void))block | |
{ | |
if ([UIAlertController class]) { | |
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title | |
message:message | |
preferredStyle:UIAlertControllerStyleAlert]; |
This file contains hidden or 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
// Observed bug(?): When adding a button after creating UIAlertView, the firstOtherButtonIndex value | |
// is stuck as -1 instead of the correct value, 1, even though the documentation states that the two | |
// invocations below should be equivalent. | |
NSString *closeText = @"Cancel"; | |
NSString *actionText = @"OK"; | |
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title | |
message:message | |
delegate:self |
This file contains hidden or 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
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)recognizer { | |
if (recognizer != self.panGestureRecognizer) { | |
if ([super respondsToSelector:@selector(gestureRecognizerShouldBegin:)]) { | |
return [super gestureRecognizerShouldBegin:recognizer]; | |
} else { | |
return YES; | |
} | |
} | |
CGPoint translation = [recognizer translationInView:self]; |
This file contains hidden or 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
// Playground: http://play.golang.org/p/G9-_EtwPRg | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
type WorkerId int |